• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with form_textarea (and probably other form helpers)

I've found that form_textarea is generating spurious output when the 'rows' and 'cols' attribute values are set in the third (extras) parameter. I have a call of


which generates the output

<textarea name="del_instr" cols="40" rows="10"  cols="50" rows="3"></textarea>

where the cols and rows attributes are duplicated.

In CI3.0.1 changelog there is the note 'Added support for passing the “extra” parameter as an array to all Form Helper functions that use it.', and I find this new scheme much more intuitive and consistent across the various field generators. Previous versions required that if you wanted to submit an array, it had to be the first parameter and therefore had to include the name and value parameters.

Looking in system/helpers/form_helper.php at the code for form_textarea, the code first sets up defaults for the attributes 'cols' (40) and 'rows' (10), and then calls _parse_form_attributes to check whether these attributes are set in the first parameter to form_textarea (assuming it to be an array). But if the defaulted values are specified in the third parameter (which can now be an array) the defaults are emitted as well as the specified values.

To fix this, it looks as though _parse_form_attributes needs to check the third parameter to form_textarea as well as the first for values for the default attributes. I believe this will apply to all the other field generators that use it.

Also, should these default values be mentioned in the documentation?

-- or am I missing something? The docs say the first parameter is an array ($data (array) – Field attributes data) but then suggests that it can instead be the field name as a string. Further on states $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string. Nowhere can I find mention of which attributes belong in which array.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.