FOF30\Form\Form::getModel PHP Method

getModel() public method

Returns the DataModel attached to this form
public getModel ( ) : DataModel
return FOF30\Model\DataModel
    public function &getModel()
    {
        return $this->model;
    }

Usage Example

Example #1
0
File: User.php Project: Joal01/fof
 /**
  * Replace string with tags that reference fields
  *
  * @param   string  $text  Text to process
  *
  * @return  string         Text with tags replace
  */
 protected function parseFieldTags($text)
 {
     $ret = $text;
     // Replace [ITEM:ID] in the URL with the item's key value (usually:
     // the auto-incrementing numeric ID)
     if (is_null($this->item)) {
         $this->item = $this->form->getModel();
     }
     $keyfield = $this->item->getKeyName();
     $replace = $this->item->{$keyfield};
     $ret = str_replace('[ITEM:ID]', $replace, $ret);
     // Replace the [ITEMID] in the URL with the current Itemid parameter
     $ret = str_replace('[ITEMID]', $this->form->getContainer()->input->getInt('Itemid', 0), $ret);
     // Replace other field variables in the URL
     $fields = $this->item->getTableFields();
     foreach ($fields as $fielddata) {
         $fieldname = $fielddata->Field;
         if (empty($fieldname)) {
             $fieldname = $fielddata->column_name;
         }
         $search = '[ITEM:' . strtoupper($fieldname) . ']';
         $replace = $this->item->{$fieldname};
         if (!is_string($replace)) {
             continue;
         }
         $ret = str_replace($search, $replace, $ret);
     }
     return $ret;
 }
All Usage Examples Of FOF30\Form\Form::getModel