I'm building my first extension with a basic Quickform. I'm trying to figure out the options I have for different field types, but I'm not seeing where the documentation is on definitions of types, especially the extended types. For example, the Developer Docs talk about deprecated types for dates, and they mention using datepicker, but where would I find all the options I have available to me for the datepicker type? In this case, I'd like to have a datepicker without the time part, or set the minimum date. But same goes for other types as well, I'm not seeing the documentation or examples. Where can I get more details on each extended type and/or examples of use?
For most uses of
CRM_Core_Form->add(), all the arguments you need are in the docblock:
/** * Simple easy to use wrapper around addElement. * * Deal with simple validation rules. * * @param string $type * @param string $name * @param string $label * @param string|array $attributes (options for select elements) * @param bool $required * @param array $extra * (attributes for select elements). * For datepicker elements this is consistent with the data * from CRM_Utils_Date::getDatePickerExtra * * @return HTML_QuickForm_Element * Could be an error object */
Datepicker is a special case, and is documented separately. I found this by searching
CRM_Core_Form for "datepicker" and found a reference to this as a comment.
As some unasked for commentary - if you can find any way to NOT use Quickform, I highly recommend it. It's pretty much every Civi dev's least favorite part of Civi, and there's an active effort to replace it. Consider using AJAX/API wherever possible to make your life easier!
I usually find more detailed examples by looking in the CiviCRM code, which is exactly where I found the answer to the " i do not want time" question a while ago :-) As I found it I can share it with you:
$this->add('datepicker', 'activity_compare_date', ts('Comparison Date'), array('placeholder' => ts('Compare with')),FALSE, array('time' => FALSE));
And yes,it would be ideal if all these examples would be in the developer guide. So I would like to invite you to the next CiviCRM sprint to make this happen :-)