#5303: FormHelper::Input() should allow placing content AFTER an error message
----------------------------+-----------------------------------------------
Reporter: kiger | Owner:
Type: Enhancement | Status: new
Priority: Medium | Milestone:
Component: Helpers | Version:
Severity: Normal | Resolution:
Keywords: 1.2 | Php_version: n/a
Cake_version: 7483 |
----------------------------+-----------------------------------------------
Comment (by thajeztah):
== Patch to override formatting of inputs ==
Sorry for the long time before responding. Things have been quite busy
here.
I've created a patch for my proposal. The patch is against formhelper
form.php, revision 7805 (CakePHP revision 7856)
Although my original idea was to use 'sprintf' for formatting, I decided
to use the CakePHP String::insert function. For performance, sprintf will
be faster, but more difficult to understand. Format-strings for
String::insert will be a lot easier to use and less prone to mistakes.
== What's in this Patch? ==
I've added a new property 'inputFormats' to the formhelper, which contains
formats for each input-type (currently: 'hidden', 'checkbox' and 'default'
for all other input-types).
The 'input' method now accepts 'inputFormat' as an option in the options-
array. Using this option it's possible to override the format for a single
field
To override the format for all fields of a specific type, modify
form::inputFormat and add or modify the index for that input-type.
== Examples ==
'''Create a form for the 'Customer' model'''
{{{
echo $form->create('Customer');
}}}
'''Override the format format for the 'surname' field using 'inputFormat'
in options-array
'''
{{{
echo $form->input('Customer.surname', array('inputFormat' =>
'<fieldset><legend>this is a custom
legend</legend>:before:label:between:input:after:errmsg</fieldset>'));
}}}
'''Add some extra text before the 'address' input using 'inputFormat' in
options-array
'''
{{{
echo $form->input('Customer.address', array('inputFormat' => '<p>Please
supply your address:</p>:before:label:between:input:after:errmsg'));
}}}
'''Or... using the 'before' option (still works after applying the
path)'''
{{{
echo $form->input('Customer.address', array('before' => '<p>Please supply
your address:</p>'));
}}}
'''
Override the format for all date fields; Put the label -after- the input
for all date fields by modifying the 'inputFormats' array.'''
{{{
$form->inputFormats['date'] = ':before:input:between:label:after:errmsg';
echo $form->inputs();
}}}
'''Close the form:'''
{{{
echo $form->end();
}}}
== Summary ==
This patch:
* Allows overriding the format for individual fields/inputs
* Allows overriding the format for all fields of a type
* Is backwards compatible; all current options are preserved
* Is easy to use/understand by using String::insert()
All comments are welcome, hopefully this patch will be integrated into
CakePHP 1.2
--
Ticket URL: <https://trac.cakephp.org/ticket/5303#comment:9>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---