php-bootstrap-form
php-bootstrap-form copied to clipboard
Problem with hidden value
I am using this code which has been working great, however, I have a slight issue with the hidden field. The attributes for a hidden field takes a string (In the documentation it says it takes an array), not an array which every other field takes. Can you please add a check in there that if an array is passed that it grabs the value field and converts it to a string?
can you please provide a sample please?
Sure, so when you call the form builder for any other functions, you call it like this:
$form = Form::open( "form", NULL, array(
"prevent" => array(
"bootstrap",
"jQuery",
"jqueryui"
)
) );
$form_class->Select( String $label, String $id, $options, Array $attributes = array( 'value' => 'somevalue' ) );
$form->close( FALSE );
However, when you use the Hidden one, it is used like this:
$form_class->Hidden( String $id, String 'somevalue' );
When I was working with it I was trying to figure out what was wrong because I was passing an array into that field with the option value like every other field type and it was hard to figure out what was wrong. What I am proposing is to add an option to check if it is an array for Hidden and if so, convert it to a string automatically instead of throwing an error.
I would have added it myself and sent it to you for a potential merge, but I am not sure how to do that in github.
Hope that is easy to understand.