Hi All, Pardon the cross-post but I thought this was important enough to make sure it got to all the necessary places. Some of you may have noticed a new form package in the Joomla 1.6 trunk. The new form package provides a robust API for creating, populating, filtering, and validating form data via XML and PHP. The forms are created with XML similar to JParameter but JForm is powerful enough to be used for a complete form, not just a set of parameters.
Filtering
By defining a filter attribute on each form field, JForm will allow you to completely sanitize your form input with one API call. The filter attribute will accept a variety of values including "unset" for read only data, "safehtml" for limited HTML support, "raw" for full HTML support, all JFilterInput::clean() mechanisms including "integer", "boolean", "base64", etc. as well as callbacks in the form of "my_callback_method" or "JFilterOutput::stringUrlSafe".
Validation
By defining a validate attribute for each form field, JForm will also validate form data. Some simple rules are available right now but there will probably be more coming in the near future. To validate an e-mail address, you can use validate="email" and the e-mail validator takes an optional attribute unique="unique" which will validate that the e-mail address is not in use by another user. If you use the unique option, you have to also specify a key for the user's table. It is easy to build your own validation rules and they can be combined to create some pretty sophisticated validation logic.
<field name="email1" type="text" id="email1" label="PROFILE FORM EMAIL1 LABEL" description="PROFILE FORM EMAIL1 LABEL" message="PROFILE FORM EMAIL1 MESSAGE" class="inputbox validate-email" size="30" default="" required="true" filter="string" validate="email" field="id" unique="true" />
<field name="email2" type="text" id="email2" label="PROFILE FORM EMAIL2 LABEL" description="PROFILE FORM EMAIL2 LABEL" message="PROFILE FORM EMAIL2 MESSAGE" class="inputbox validate-email" size="30" default="" required="true" filter="string" validate="equals" field="email1" />
The field definitions could be used in a user data edit screen to ensure that the user's e-mail address is unique to that user and that the email1 and email2 fields match. The email1 field will validate that the e-mail address is unique to the user and the email2 field will verify that it's supplied value matches the value given to email1. You can also specify custom validation messages via the message attribute.
Getting A Form
Let's assume you have an MVC component with a "forms" folder within the "models" folder. In the forms folder, you have a form file named "profile.xml". To get a instance of the form you would do something like:
// Get the form. jimport('joomla.form.form'); JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms'); $form = &JForm::getInstance('jform', 'profile', true, array('array' => true));
JForm::addFormPath() works similarly to JModel::addIncludePath or JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance. The first parameter is a name to identify the form by and will come into play when with the array option that you see in the forth parameter. The second parameter, "profile", tells JForm where to get the XML data from and the third option indicates that "profile" is a file name. Instead of specifying a file name, you can pass in straight XML into the second parameter and set the third parameter to false. The fourth parameter, array('array' => true), tells JForm to render the individual field names as an array. If our profile.xml contained the fields posted above, the field names would be jform[id], jform[email1], and jform[email2]. If the array option is set to false, the field names would be rendered as id, email1, and email2.
The array option is very convenient because it makes loading the form data and running it through the filter/validator extremely quick.
// Get the form. jimport('joomla.form.form'); JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms'); $form = &JForm::getInstance('jform', 'profile', true, array('array' => true));
// Get the profile data. $data = JRequest::getVar('jform', array(), 'post', 'array');
// Filter and validate the form data. $data = $form->filter($data); $return = $form->validate($data);
// Check for errors and save...
Notes
* We are still sorting out some of the error handling and validation warning feedback for PHP 5.2. The error handling will probably be updated in the near future to make distinguishing hard errors from validation errors easier.
* The library as a whole is quite powerful and I hope that it is fairly easy to understand but it will probably require some trial and error to really get the hang of. The newly committed com_weblinks admin component should serve as a useful example of how to use the new form package and the access control system will begin to use it more in the near future.
That is all I can think of right now but I'm sure I've probably forgot something. If you guys have any questions, feel free to ask and I will do my best to help you out.
> Hi All,
> Pardon the cross-post but I thought this was important enough to make sure
> it got to all the necessary places. Some of you may have noticed a new form
> package in the Joomla 1.6 trunk. The new form package provides a robust API
> for creating, populating, filtering, and validating form data via XML and
> PHP. The forms are created with XML similar to JParameter but JForm is
> powerful enough to be used for a complete form, not just a set of
> parameters.
> Filtering
> By defining a filter attribute on each form field, JForm will allow you to
> completely sanitize your form input with one API call. The filter attribute
> will accept a variety of values including "unset" for read only data,
> "safehtml" for limited HTML support, "raw" for full HTML support, all
> JFilterInput::clean() mechanisms including "integer", "boolean", "base64",
> etc. as well as callbacks in the form of "my_callback_method" or
> "JFilterOutput::stringUrlSafe".
> Validation
> By defining a validate attribute for each form field, JForm will also
> validate form data. Some simple rules are available right now but there will
> probably be more coming in the near future. To validate an e-mail address,
> you can use validate="email" and the e-mail validator takes an optional
> attribute unique="unique" which will validate that the e-mail address is not
> in use by another user. If you use the unique option, you have to also
> specify a key for the user's table. It is easy to build your own validation
> rules and they can be combined to create some pretty sophisticated
> validation logic.
> The field definitions could be used in a user data edit screen to ensure
> that the user's e-mail address is unique to that user and that the email1
> and email2 fields match. The email1 field will validate that the e-mail
> address is unique to the user and the email2 field will verify that it's
> supplied value matches the value given to email1. You can also specify
> custom validation messages via the message attribute.
> Getting A Form
> Let's assume you have an MVC component with a "forms" folder within the
> "models" folder. In the forms folder, you have a form file named
> "profile.xml". To get a instance of the form you would do something like:
> // Get the form.
> jimport('joomla.form.form');
> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
> true));
> JForm::addFormPath() works similarly to JModel::addIncludePath or
> JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance. The
> first parameter is a name to identify the form by and will come into play
> when with the array option that you see in the forth parameter. The second
> parameter, "profile", tells JForm where to get the XML data from and the
> third option indicates that "profile" is a file name. Instead of specifying
> a file name, you can pass in straight XML into the second parameter and set
> the third parameter to false. The fourth parameter, array('array' => true),
> tells JForm to render the individual field names as an array. If our
> profile.xml contained the fields posted above, the field names would be
> jform[id], jform[email1], and jform[email2]. If the array option is set to
> false, the field names would be rendered as id, email1, and email2.
> The array option is very convenient because it makes loading the form data
> and running it through the filter/validator extremely quick.
> // Get the form.
> jimport('joomla.form.form');
> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
> true));
> // Get the profile data.
> $data = JRequest::getVar('jform', array(), 'post', 'array');
> // Filter and validate the form data.
> $data = $form->filter($data);
> $return = $form->validate($data);
> // Check for errors and save...
> Notes
> * We are still sorting out some of the error handling and validation warning
> feedback for PHP 5.2. The error handling will probably be updated in the
> near future to make distinguishing hard errors from validation errors
> easier.
> * The library as a whole is quite powerful and I hope that it is fairly easy
> to understand but it will probably require some trial and error to really
> get the hang of. The newly committed com_weblinks admin component should
> serve as a useful example of how to use the new form package and the access
> control system will begin to use it more in the near future.
> That is all I can think of right now but I'm sure I've probably forgot
> something. If you guys have any questions, feel free to ask and I will do my
> best to help you out.
> Hi All,
> Pardon the cross-post but I thought this was important enough to make sure
> it got to all the necessary places. Some of you may have noticed a new form
> package in the Joomla 1.6 trunk. The new form package provides a robust API
> for creating, populating, filtering, and validating form data via XML and
> PHP. The forms are created with XML similar to JParameter but JForm is
> powerful enough to be used for a complete form, not just a set of
> parameters.
> Filtering
> By defining a filter attribute on each form field, JForm will allow you to
> completely sanitize your form input with one API call. The filter attribute
> will accept a variety of values including "unset" for read only data,
> "safehtml" for limited HTML support, "raw" for full HTML support, all
> JFilterInput::clean() mechanisms including "integer", "boolean", "base64",
> etc. as well as callbacks in the form of "my_callback_method" or
> "JFilterOutput::stringUrlSafe".
> Validation
> By defining a validate attribute for each form field, JForm will also
> validate form data. Some simple rules are available right now but there will
> probably be more coming in the near future. To validate an e-mail address,
> you can use validate="email" and the e-mail validator takes an optional
> attribute unique="unique" which will validate that the e-mail address is not
> in use by another user. If you use the unique option, you have to also
> specify a key for the user's table. It is easy to build your own validation
> rules and they can be combined to create some pretty sophisticated
> validation logic.
> The field definitions could be used in a user data edit screen to ensure
> that the user's e-mail address is unique to that user and that the email1
> and email2 fields match. The email1 field will validate that the e-mail
> address is unique to the user and the email2 field will verify that it's
> supplied value matches the value given to email1. You can also specify
> custom validation messages via the message attribute.
> Getting A Form
> Let's assume you have an MVC component with a "forms" folder within the
> "models" folder. In the forms folder, you have a form file named
> "profile.xml". To get a instance of the form you would do something like:
> // Get the form.
> jimport('joomla.form.form');
> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
> true));
> JForm::addFormPath() works similarly to JModel::addIncludePath or
> JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance. The
> first parameter is a name to identify the form by and will come into play
> when with the array option that you see in the forth parameter. The second
> parameter, "profile", tells JForm where to get the XML data from and the
> third option indicates that "profile" is a file name. Instead of specifying
> a file name, you can pass in straight XML into the second parameter and set
> the third parameter to false. The fourth parameter, array('array' => true),
> tells JForm to render the individual field names as an array. If our
> profile.xml contained the fields posted above, the field names would be
> jform[id], jform[email1], and jform[email2]. If the array option is set to
> false, the field names would be rendered as id, email1, and email2.
> The array option is very convenient because it makes loading the form data
> and running it through the filter/validator extremely quick.
> // Get the form.
> jimport('joomla.form.form');
> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
> true));
> // Get the profile data.
> $data = JRequest::getVar('jform', array(), 'post', 'array');
> // Filter and validate the form data.
> $data = $form->filter($data);
> $return = $form->validate($data);
> // Check for errors and save...
> Notes
> * We are still sorting out some of the error handling and validation warning
> feedback for PHP 5.2. The error handling will probably be updated in the
> near future to make distinguishing hard errors from validation errors
> easier.
> * The library as a whole is quite powerful and I hope that it is fairly easy
> to understand but it will probably require some trial and error to really
> get the hang of. The newly committed com_weblinks admin component should
> serve as a useful example of how to use the new form package and the access
> control system will begin to use it more in the near future.
> That is all I can think of right now but I'm sure I've probably forgot
> something. If you guys have any questions, feel free to ask and I will do my
> best to help you out.
> Hi,
> could this library be added to Joomla 1.5 core without expecting J1.6
> release?
> Cristiano
> On 26 Gen, 09:03, Rob Schley <rob.sch...@community.joomla.org> wrote:
> > Hi All,
> > Pardon the cross-post but I thought this was important enough to make
> sure
> > it got to all the necessary places. Some of you may have noticed a new
> form
> > package in the Joomla 1.6 trunk. The new form package provides a robust
> API
> > for creating, populating, filtering, and validating form data via XML and
> > PHP. The forms are created with XML similar to JParameter but JForm is
> > powerful enough to be used for a complete form, not just a set of
> > parameters.
> > Filtering
> > By defining a filter attribute on each form field, JForm will allow you
> to
> > completely sanitize your form input with one API call. The filter
> attribute
> > will accept a variety of values including "unset" for read only data,
> > "safehtml" for limited HTML support, "raw" for full HTML support, all
> > JFilterInput::clean() mechanisms including "integer", "boolean",
> "base64",
> > etc. as well as callbacks in the form of "my_callback_method" or
> > "JFilterOutput::stringUrlSafe".
> > Validation
> > By defining a validate attribute for each form field, JForm will also
> > validate form data. Some simple rules are available right now but there
> will
> > probably be more coming in the near future. To validate an e-mail
> address,
> > you can use validate="email" and the e-mail validator takes an optional
> > attribute unique="unique" which will validate that the e-mail address is
> not
> > in use by another user. If you use the unique option, you have to also
> > specify a key for the user's table. It is easy to build your own
> validation
> > rules and they can be combined to create some pretty sophisticated
> > validation logic.
> > The field definitions could be used in a user data edit screen to ensure
> > that the user's e-mail address is unique to that user and that the email1
> > and email2 fields match. The email1 field will validate that the e-mail
> > address is unique to the user and the email2 field will verify that it's
> > supplied value matches the value given to email1. You can also specify
> > custom validation messages via the message attribute.
> > Getting A Form
> > Let's assume you have an MVC component with a "forms" folder within the
> > "models" folder. In the forms folder, you have a form file named
> > "profile.xml". To get a instance of the form you would do something like:
> > JForm::addFormPath() works similarly to JModel::addIncludePath or
> > JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance.
> The
> > first parameter is a name to identify the form by and will come into play
> > when with the array option that you see in the forth parameter. The
> second
> > parameter, "profile", tells JForm where to get the XML data from and the
> > third option indicates that "profile" is a file name. Instead of
> specifying
> > a file name, you can pass in straight XML into the second parameter and
> set
> > the third parameter to false. The fourth parameter, array('array' =>
> true),
> > tells JForm to render the individual field names as an array. If our
> > profile.xml contained the fields posted above, the field names would be
> > jform[id], jform[email1], and jform[email2]. If the array option is set
> to
> > false, the field names would be rendered as id, email1, and email2.
> > The array option is very convenient because it makes loading the form
> data
> > and running it through the filter/validator extremely quick.
> > // Get the profile data.
> > $data = JRequest::getVar('jform', array(), 'post', 'array');
> > // Filter and validate the form data.
> > $data = $form->filter($data);
> > $return = $form->validate($data);
> > // Check for errors and save...
> > Notes
> > * We are still sorting out some of the error handling and validation
> warning
> > feedback for PHP 5.2. The error handling will probably be updated in the
> > near future to make distinguishing hard errors from validation errors
> > easier.
> > * The library as a whole is quite powerful and I hope that it is fairly
> easy
> > to understand but it will probably require some trial and error to really
> > get the hang of. The newly committed com_weblinks admin component should
> > serve as a useful example of how to use the new form package and the
> access
> > control system will begin to use it more in the near future.
> > That is all I can think of right now but I'm sure I've probably forgot
> > something. If you guys have any questions, feel free to ask and I will do
> my
> > best to help you out.
> Hi,
> could this library be added to Joomla 1.5 core without expecting J1.6
> release?
> Cristiano
> On 26 Gen, 09:03, Rob Schley <rob.sch...@community.joomla.org> wrote:
>> Hi All,
>> Pardon the cross-post but I thought this was important enough to make sure
>> it got to all the necessary places. Some of you may have noticed a new form
>> package in the Joomla 1.6 trunk. The new form package provides a robust API
>> for creating, populating, filtering, and validating form data via XML and
>> PHP. The forms are created with XML similar to JParameter but JForm is
>> powerful enough to be used for a complete form, not just a set of
>> parameters.
>> Filtering
>> By defining a filter attribute on each form field, JForm will allow you to
>> completely sanitize your form input with one API call. The filter attribute
>> will accept a variety of values including "unset" for read only data,
>> "safehtml" for limited HTML support, "raw" for full HTML support, all
>> JFilterInput::clean() mechanisms including "integer", "boolean", "base64",
>> etc. as well as callbacks in the form of "my_callback_method" or
>> "JFilterOutput::stringUrlSafe".
>> Validation
>> By defining a validate attribute for each form field, JForm will also
>> validate form data. Some simple rules are available right now but there will
>> probably be more coming in the near future. To validate an e-mail address,
>> you can use validate="email" and the e-mail validator takes an optional
>> attribute unique="unique" which will validate that the e-mail address is not
>> in use by another user. If you use the unique option, you have to also
>> specify a key for the user's table. It is easy to build your own validation
>> rules and they can be combined to create some pretty sophisticated
>> validation logic.
>> The field definitions could be used in a user data edit screen to ensure
>> that the user's e-mail address is unique to that user and that the email1
>> and email2 fields match. The email1 field will validate that the e-mail
>> address is unique to the user and the email2 field will verify that it's
>> supplied value matches the value given to email1. You can also specify
>> custom validation messages via the message attribute.
>> Getting A Form
>> Let's assume you have an MVC component with a "forms" folder within the
>> "models" folder. In the forms folder, you have a form file named
>> "profile.xml". To get a instance of the form you would do something like:
>> // Get the form.
>> jimport('joomla.form.form');
>> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
>> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
>> true));
>> JForm::addFormPath() works similarly to JModel::addIncludePath or
>> JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance. The
>> first parameter is a name to identify the form by and will come into play
>> when with the array option that you see in the forth parameter. The second
>> parameter, "profile", tells JForm where to get the XML data from and the
>> third option indicates that "profile" is a file name. Instead of specifying
>> a file name, you can pass in straight XML into the second parameter and set
>> the third parameter to false. The fourth parameter, array('array' => true),
>> tells JForm to render the individual field names as an array. If our
>> profile.xml contained the fields posted above, the field names would be
>> jform[id], jform[email1], and jform[email2]. If the array option is set to
>> false, the field names would be rendered as id, email1, and email2.
>> The array option is very convenient because it makes loading the form data
>> and running it through the filter/validator extremely quick.
>> // Get the form.
>> jimport('joomla.form.form');
>> JForm::addFormPath(JPATH_COMPONENT.DS.'models'.DS.'forms');
>> $form = &JForm::getInstance('jform', 'profile', true, array('array' =>
>> true));
>> // Get the profile data.
>> $data = JRequest::getVar('jform', array(), 'post', 'array');
>> // Filter and validate the form data.
>> $data = $form->filter($data);
>> $return = $form->validate($data);
>> // Check for errors and save...
>> Notes
>> * We are still sorting out some of the error handling and validation warning
>> feedback for PHP 5.2. The error handling will probably be updated in the
>> near future to make distinguishing hard errors from validation errors
>> easier.
>> * The library as a whole is quite powerful and I hope that it is fairly easy
>> to understand but it will probably require some trial and error to really
>> get the hang of. The newly committed com_weblinks admin component should
>> serve as a useful example of how to use the new form package and the access
>> control system will begin to use it more in the near future.
>> That is all I can think of right now but I'm sure I've probably forgot
>> something. If you guys have any questions, feel free to ask and I will do my
>> best to help you out.
There will be many differences between offical 1.6 JForm and Jxtended
version?
I mean If I develop a component using it, will be compatible with
future 1.6 release
or will I have to include again JXtende libraries?
Thank you,
Cristiano
On 21 Feb, 23:08, Andrew Eddie <mambob...@gmail.com> wrote:
> > Hi,
> > could this library be added to Joomla 1.5 core without expecting J1.6
> > release?
> > Cristiano
> > On 26 Gen, 09:03, Rob Schley <rob.sch...@community.joomla.org> wrote:
> >> Hi All,
> >> Pardon the cross-post but I thought this was important enough to make sure
> >> it got to all the necessary places. Some of you may have noticed a new form
> >> package in the Joomla 1.6 trunk. The new form package provides a robust API
> >> for creating, populating, filtering, and validating form data via XML and
> >> PHP. The forms are created with XML similar to JParameter but JForm is
> >> powerful enough to be used for a complete form, not just a set of
> >> parameters.
> >> Filtering
> >> By defining a filter attribute on each form field, JForm will allow you to
> >> completely sanitize your form input with one API call. The filter attribute
> >> will accept a variety of values including "unset" for read only data,
> >> "safehtml" for limited HTML support, "raw" for full HTML support, all
> >> JFilterInput::clean() mechanisms including "integer", "boolean", "base64",
> >> etc. as well as callbacks in the form of "my_callback_method" or
> >> "JFilterOutput::stringUrlSafe".
> >> Validation
> >> By defining a validate attribute for each form field, JForm will also
> >> validate form data. Some simple rules are available right now but there will
> >> probably be more coming in the near future. To validate an e-mail address,
> >> you can use validate="email" and the e-mail validator takes an optional
> >> attribute unique="unique" which will validate that the e-mail address is not
> >> in use by another user. If you use the unique option, you have to also
> >> specify a key for the user's table. It is easy to build your own validation
> >> rules and they can be combined to create some pretty sophisticated
> >> validation logic.
> >> The field definitions could be used in a user data edit screen to ensure
> >> that the user's e-mail address is unique to that user and that the email1
> >> and email2 fields match. The email1 field will validate that the e-mail
> >> address is unique to the user and the email2 field will verify that it's
> >> supplied value matches the value given to email1. You can also specify
> >> custom validation messages via the message attribute.
> >> Getting A Form
> >> Let's assume you have an MVC component with a "forms" folder within the
> >> "models" folder. In the forms folder, you have a form file named
> >> "profile.xml". To get a instance of the form you would do something like:
> >> JForm::addFormPath() works similarly to JModel::addIncludePath or
> >> JHtml::addIncludePath(). JForm::getInstance() returns a JForm instance. The
> >> first parameter is a name to identify the form by and will come into play
> >> when with the array option that you see in the forth parameter. The second
> >> parameter, "profile", tells JForm where to get the XML data from and the
> >> third option indicates that "profile" is a file name. Instead of specifying
> >> a file name, you can pass in straight XML into the second parameter and set
> >> the third parameter to false. The fourth parameter, array('array' => true),
> >> tells JForm to render the individual field names as an array. If our
> >> profile.xml contained the fields posted above, the field names would be
> >> jform[id], jform[email1], and jform[email2]. If the array option is set to
> >> false, the field names would be rendered as id, email1, and email2.
> >> The array option is very convenient because it makes loading the form data
> >> and running it through the filter/validator extremely quick.
> >> // Get the profile data.
> >> $data = JRequest::getVar('jform', array(), 'post', 'array');
> >> // Filter and validate the form data.
> >> $data = $form->filter($data);
> >> $return = $form->validate($data);
> >> // Check for errors and save...
> >> Notes
> >> * We are still sorting out some of the error handling and validation warning
> >> feedback for PHP 5.2. The error handling will probably be updated in the
> >> near future to make distinguishing hard errors from validation errors
> >> easier.
> >> * The library as a whole is quite powerful and I hope that it is fairly easy
> >> to understand but it will probably require some trial and error to really
> >> get the hang of. The newly committed com_weblinks admin component should
> >> serve as a useful example of how to use the new form package and the access
> >> control system will begin to use it more in the near future.
> >> That is all I can think of right now but I'm sure I've probably forgot
> >> something. If you guys have any questions, feel free to ask and I will do my
> >> best to help you out.
I believe in the JXtended libraries the class is named "JXForm" vs. the name
"JForm" which will be the official name in Joomla 1.6.
The API should be similar for both classes so to convert your code later all
you would need to do I believe is do some renaming in your code.
For Joomla 1.5, if you do decide to use the JXtended libraries, you will
have to tell your users that they will need the libraries installed if your
component is to work (or you can take parts of the library that you need and
just include them in your code).
Hopefully that makes things a little clearer,
-Omar
On Sun, Feb 22, 2009 at 9:43 AM, cristiano.cucco
<cristiano.cu...@gmail.com>wrote:
> There will be many differences between offical 1.6 JForm and Jxtended
> version?
> I mean If I develop a component using it, will be compatible with
> future 1.6 release
> or will I have to include again JXtende libraries?
> Thank you,
> Cristiano
> On 21 Feb, 23:08, Andrew Eddie <mambob...@gmail.com> wrote:
> > It's part of our JXtended libraries (available from jxtended.com). If
> > you want to use it in 1.5, just grab our libraries.
> > > Hi,
> > > could this library be added to Joomla 1.5 core without expecting J1.6
> > > release?
> > > Cristiano
> > > On 26 Gen, 09:03, Rob Schley <rob.sch...@community.joomla.org> wrote:
> > >> Hi All,
> > >> Pardon the cross-post but I thought this was important enough to make
> sure
> > >> it got to all the necessary places. Some of you may have noticed a new
> form
> > >> package in the Joomla 1.6 trunk. The new form package provides a
> robust API
> > >> for creating, populating, filtering, and validating form data via XML
> and
> > >> PHP. The forms are created with XML similar to JParameter but JForm
> is
> > >> powerful enough to be used for a complete form, not just a set of
> > >> parameters.
> > >> Filtering
> > >> By defining a filter attribute on each form field, JForm will allow
> you to
> > >> completely sanitize your form input with one API call. The filter
> attribute
> > >> will accept a variety of values including "unset" for read only data,
> > >> "safehtml" for limited HTML support, "raw" for full HTML support, all
> > >> JFilterInput::clean() mechanisms including "integer", "boolean",
> "base64",
> > >> etc. as well as callbacks in the form of "my_callback_method" or
> > >> "JFilterOutput::stringUrlSafe".
> > >> Validation
> > >> By defining a validate attribute for each form field, JForm will also
> > >> validate form data. Some simple rules are available right now but
> there will
> > >> probably be more coming in the near future. To validate an e-mail
> address,
> > >> you can use validate="email" and the e-mail validator takes an
> optional
> > >> attribute unique="unique" which will validate that the e-mail address
> is not
> > >> in use by another user. If you use the unique option, you have to also
> > >> specify a key for the user's table. It is easy to build your own
> validation
> > >> rules and they can be combined to create some pretty sophisticated
> > >> validation logic.
> > >> The field definitions could be used in a user data edit screen to
> ensure
> > >> that the user's e-mail address is unique to that user and that the
> email1
> > >> and email2 fields match. The email1 field will validate that the
> e-mail
> > >> address is unique to the user and the email2 field will verify that
> it's
> > >> supplied value matches the value given to email1. You can also specify
> > >> custom validation messages via the message attribute.
> > >> Getting A Form
> > >> Let's assume you have an MVC component with a "forms" folder within
> the
> > >> "models" folder. In the forms folder, you have a form file named
> > >> "profile.xml". To get a instance of the form you would do something
> like:
> > >> JForm::addFormPath() works similarly to JModel::addIncludePath or
> > >> JHtml::addIncludePath(). JForm::getInstance() returns a JForm
> instance. The
> > >> first parameter is a name to identify the form by and will come into
> play
> > >> when with the array option that you see in the forth parameter. The
> second
> > >> parameter, "profile", tells JForm where to get the XML data from and
> the
> > >> third option indicates that "profile" is a file name. Instead of
> specifying
> > >> a file name, you can pass in straight XML into the second parameter
> and set
> > >> the third parameter to false. The fourth parameter, array('array' =>
> true),
> > >> tells JForm to render the individual field names as an array. If our
> > >> profile.xml contained the fields posted above, the field names would
> be
> > >> jform[id], jform[email1], and jform[email2]. If the array option is
> set to
> > >> false, the field names would be rendered as id, email1, and email2.
> > >> The array option is very convenient because it makes loading the form
> data
> > >> and running it through the filter/validator extremely quick.
> > >> // Get the profile data.
> > >> $data = JRequest::getVar('jform', array(), 'post', 'array');
> > >> // Filter and validate the form data.
> > >> $data = $form->filter($data);
> > >> $return = $form->validate($data);
> > >> // Check for errors and save...
> > >> Notes
> > >> * We are still sorting out some of the error handling and validation
> warning
> > >> feedback for PHP 5.2. The error handling will probably be updated in
> the
> > >> near future to make distinguishing hard errors from validation errors
> > >> easier.
> > >> * The library as a whole is quite powerful and I hope that it is
> fairly easy
> > >> to understand but it will probably require some trial and error to
> really
> > >> get the hang of. The newly committed com_weblinks admin component
> should
> > >> serve as a useful example of how to use the new form package and the
> access
> > >> control system will begin to use it more in the near future.
> > >> That is all I can think of right now but I'm sure I've probably forgot
> > >> something. If you guys have any questions, feel free to ask and I will
> do my
> > >> best to help you out.
The version in 1.6 is a bit cleaner than our current 1.5 version
(JxForm). We have a new version of libraries coming and what we will
do is keep that synchronised as much as possible with the 1.6 version.
And I've had this question before: you can by all means use the JForm
or JXForm code in your 1.5 components. It's all GPL.
> I believe in the JXtended libraries the class is named "JXForm" vs. the name
> "JForm" which will be the official name in Joomla 1.6.
> The API should be similar for both classes so to convert your code later all
> you would need to do I believe is do some renaming in your code.
> For Joomla 1.5, if you do decide to use the JXtended libraries, you will
> have to tell your users that they will need the libraries installed if your
> component is to work (or you can take parts of the library that you need and
> just include them in your code).
> Hopefully that makes things a little clearer,
> -Omar
> On Sun, Feb 22, 2009 at 9:43 AM, cristiano.cucco <cristiano.cu...@gmail.com>
> wrote:
>> There will be many differences between offical 1.6 JForm and Jxtended
>> version?
>> I mean If I develop a component using it, will be compatible with
>> future 1.6 release
>> or will I have to include again JXtende libraries?
>> Thank you,
>> Cristiano
>> On 21 Feb, 23:08, Andrew Eddie <mambob...@gmail.com> wrote:
>> > It's part of our JXtended libraries (available from jxtended.com). If
>> > you want to use it in 1.5, just grab our libraries.
>> > > Hi,
>> > > could this library be added to Joomla 1.5 core without expecting J1.6
>> > > release?
>> > > Cristiano
>> > > On 26 Gen, 09:03, Rob Schley <rob.sch...@community.joomla.org> wrote:
>> > >> Hi All,
>> > >> Pardon the cross-post but I thought this was important enough to make
>> > >> sure
>> > >> it got to all the necessary places. Some of you may have noticed a
>> > >> new form
>> > >> package in the Joomla 1.6 trunk. The new form package provides a
>> > >> robust API
>> > >> for creating, populating, filtering, and validating form data via XML
>> > >> and
>> > >> PHP. The forms are created with XML similar to JParameter but JForm
>> > >> is
>> > >> powerful enough to be used for a complete form, not just a set of
>> > >> parameters.
>> > >> Filtering
>> > >> By defining a filter attribute on each form field, JForm will allow
>> > >> you to
>> > >> completely sanitize your form input with one API call. The filter
>> > >> attribute
>> > >> will accept a variety of values including "unset" for read only data,
>> > >> "safehtml" for limited HTML support, "raw" for full HTML support, all
>> > >> JFilterInput::clean() mechanisms including "integer", "boolean",
>> > >> "base64",
>> > >> etc. as well as callbacks in the form of "my_callback_method" or
>> > >> "JFilterOutput::stringUrlSafe".
>> > >> Validation
>> > >> By defining a validate attribute for each form field, JForm will also
>> > >> validate form data. Some simple rules are available right now but
>> > >> there will
>> > >> probably be more coming in the near future. To validate an e-mail
>> > >> address,
>> > >> you can use validate="email" and the e-mail validator takes an
>> > >> optional
>> > >> attribute unique="unique" which will validate that the e-mail address
>> > >> is not
>> > >> in use by another user. If you use the unique option, you have to
>> > >> also
>> > >> specify a key for the user's table. It is easy to build your own
>> > >> validation
>> > >> rules and they can be combined to create some pretty sophisticated
>> > >> validation logic.
>> > >> The field definitions could be used in a user data edit screen to
>> > >> ensure
>> > >> that the user's e-mail address is unique to that user and that the
>> > >> email1
>> > >> and email2 fields match. The email1 field will validate that the
>> > >> e-mail
>> > >> address is unique to the user and the email2 field will verify that
>> > >> it's
>> > >> supplied value matches the value given to email1. You can also
>> > >> specify
>> > >> custom validation messages via the message attribute.
>> > >> Getting A Form
>> > >> Let's assume you have an MVC component with a "forms" folder within
>> > >> the
>> > >> "models" folder. In the forms folder, you have a form file named
>> > >> "profile.xml". To get a instance of the form you would do something
>> > >> like:
>> > >> JForm::addFormPath() works similarly to JModel::addIncludePath or
>> > >> JHtml::addIncludePath(). JForm::getInstance() returns a JForm
>> > >> instance. The
>> > >> first parameter is a name to identify the form by and will come into
>> > >> play
>> > >> when with the array option that you see in the forth parameter. The
>> > >> second
>> > >> parameter, "profile", tells JForm where to get the XML data from and
>> > >> the
>> > >> third option indicates that "profile" is a file name. Instead of
>> > >> specifying
>> > >> a file name, you can pass in straight XML into the second parameter
>> > >> and set
>> > >> the third parameter to false. The fourth parameter, array('array' =>
>> > >> true),
>> > >> tells JForm to render the individual field names as an array. If our
>> > >> profile.xml contained the fields posted above, the field names would
>> > >> be
>> > >> jform[id], jform[email1], and jform[email2]. If the array option is
>> > >> set to
>> > >> false, the field names would be rendered as id, email1, and email2.
>> > >> The array option is very convenient because it makes loading the form
>> > >> data
>> > >> and running it through the filter/validator extremely quick.
>> > >> // Get the profile data.
>> > >> $data = JRequest::getVar('jform', array(), 'post', 'array');
>> > >> // Filter and validate the form data.
>> > >> $data = $form->filter($data);
>> > >> $return = $form->validate($data);
>> > >> // Check for errors and save...
>> > >> Notes
>> > >> * We are still sorting out some of the error handling and validation
>> > >> warning
>> > >> feedback for PHP 5.2. The error handling will probably be updated in
>> > >> the
>> > >> near future to make distinguishing hard errors from validation errors
>> > >> easier.
>> > >> * The library as a whole is quite powerful and I hope that it is
>> > >> fairly easy
>> > >> to understand but it will probably require some trial and error to
>> > >> really
>> > >> get the hang of. The newly committed com_weblinks admin component
>> > >> should
>> > >> serve as a useful example of how to use the new form package and the
>> > >> access
>> > >> control system will begin to use it more in the near future.
>> > >> That is all I can think of right now but I'm sure I've probably
>> > >> forgot
>> > >> something. If you guys have any questions, feel free to ask and I
>> > >> will do my
>> > >> best to help you out.