$field = DropdownAttributesField::create(
'Count',
'Count',
array(
'1' => 'One',
'2' => 'Two',
'3' => 'Three'
)
)->setOptionsAttributes(
'data-bats',
array(
'1' => 'batty',
'2' => 'batty batty',
'3' => 'batty batty batty',
)
);
Generates code like:
<div id="Count" class="control-group form-group">
<label for="Form_Form_Count">Count</label>
<select name="Count" class="dropdownattributes form-control" id="Form_CountingForm_Count">
<option value="1" data-bats="batty">One</option>
<option value="2" data-bats="batty batty">Two</option>
<option value="3" data-bats="batty batty batty">Three</option>
</select>
</div>
Would there be enough interest in this feature to add it to core or
would that just be bloat?Marijn
Kampf
Exadium - Online Marketing & Web Development
mar...@exadium.com / www.exadium.com
uk mobile: 07 525 49 9234 / uk landline: 01446
620 436 / nl telefoon: 0357 110 379
international mobile: 0044 7525 49 9234 / phone uk:
0044 1446 620 436 / phone nl: 0031 35 71 10 379
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.
in favour of adding something like this to core: since SilverStripe already supports adding attributes to formfields, why should options be an exception and need their own module?
--
Marijn
Yeah, this really speaks to the bigger issue that there's just no API for the options themselves. That the $Options array is computed in the Field() method is particularly problematic, because there's no way to really overload it. (This wreaked havoc on my display-logic module). A getOptions() method would make these fields much more customisable.