cakephp

Page 70

Helpers

tagErrorMsg($fieldName, $message); string $fieldName; string $message; The HTML helper also includes a set of functions that aid in creating date-related option tags. The $tagName parameter should be handled in the same way as the $fieldName parameter. Just provide the name of the field this date option tag is relevant to. Once the data is processed, you'll see it in your controller with the part of the date it handles concatenated to the end of the field name. For example, if my Note had a deadline field that was a date, and my dayOptionTag $tagName parameter was set to 'note/deadline', the day data would show up in the $params variable once the form has been submitted to a controller action: $this->data['Note']['deadline_day']

You can then use this information to concatenate the time data in a format that is friendly to your current database configuration. This code would be placed just before you attempt to save the data, and saved in the $data array used to save the information to the model.

Example 10.3. Concatenating time data before saving a model (excerpt from NotesController) function edit($id) { //First, let's check to see if any form data has been submitted to the action. if (!empty($this->data['Note'])) { //Concatenate time data for storage... $this->data['Note']['deadline'] = $this->data['Note']['deadline_year'] . "-" . $this->data['Note']['deadline_month'] . "-" . $this->data['Note']['deadline_day']; //Here's where we try to validate the form data (see Chap. 10) and save it if ($this->Note->save($this->data['Note'])) { ...

• dayOptionTag ($tagName, $value=null, $selected=null, $optionAttr=null) • yearOptionTag ($tagName, $value=null, $minYear=null, $maxYear=null, $selected=null, $optionAttr=null) • monthOptionTag ($tagName, $value=null, $selected=null, $optionAttr=null) • hourOptionTag ($tagName, $optionAttr=null)

$value=null,

$format24Hours=false,

$selected=null,

• minuteOptionTag ($tagName, $value=null, $selected=null, $optionAttr=null)

60


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.