Some arguments for UI components are optional, so we don't have to provide all of them when using them. I had added a `defined?(name)` check to use default values when an argument is not provided. Jeremy pointed out that it was working by accident. In the code `name = defined?(name)`, `defined?(name)` always returns `local-variable` because it’s on the right-hand side of the assignment, while the local variable is on the left-hand side. When we remove the `defined?` calls, the remaining code is equivalent to `||=`.
24 lines
473 B
Text
24 lines
473 B
Text
<% @enable_datepicker = true %>
|
|
|
|
<% name ||= nil
|
|
label ||= nil
|
|
default_date ||= nil
|
|
min_date ||= nil
|
|
max_date ||= nil %>
|
|
|
|
<%== render(
|
|
"components/form/text",
|
|
locals: {
|
|
label: label,
|
|
name: name,
|
|
extra_class: "datepicker",
|
|
attributes: {
|
|
"required" => true,
|
|
"placeholder" => "YYYY-MM-DD HH:MM",
|
|
"data-maxDate" => max_date,
|
|
"data-minDate" => min_date,
|
|
"data-defaultDate" => default_date,
|
|
"hidden" => true
|
|
}
|
|
}
|
|
) %>
|