FOF30\Model\DataModel::getFieldValue PHP Method

getFieldValue() public method

Returns the value of a field. If a field is not set it uses the $default value. Automatically uses magic getter variables if required.
public getFieldValue ( string $name, mixed $default = null ) : mixed
$name string The name of the field to retrieve
$default mixed Default value, if the field is not set and doesn't have a getter method
return mixed The value of the field
    public function getFieldValue($name, $default = null)
    {
        if (array_key_exists($name, $this->aliasFields)) {
            $name = $this->aliasFields[$name];
        }
        if (!array_key_exists($name, $this->knownFields)) {
            return $default;
        }
        if (!isset($this->recordData[$name])) {
            $this->recordData[$name] = $default;
        }
        return $this->recordData[$name];
    }

Usage Example

コード例 #1
0
ファイル: Actions.php プロジェクト: akeeba/fof
 /**
  * Get the rendering of this field type for a repeatable (grid) display,
  * e.g. in a view listing many item (typically a "browse" task)
  *
  * @since 2.0
  *
  * @return  string  The field HTML
  *
  * @throws  DataModelRequired
  */
 public function getRepeatable()
 {
     if (!$this->item instanceof DataModel) {
         throw new DataModelRequired(__CLASS__);
     }
     $config = $this->getConfig();
     $html = '<div class="btn-group">';
     // Render a published field
     if ($this->item->hasField('enabled')) {
         $publishedFieldName = $this->item->getFieldAlias('enabled');
         if ($config['published'] || $config['unpublished']) {
             // Generate a FieldInterfacePublished field
             $publishedField = $this->getPublishedField($publishedFieldName);
             // Render the publish button
             $html .= $publishedField->getRepeatable();
         }
         if ($config['archived']) {
             $archived = $this->item->getFieldValue($publishedFieldName) == 2 ? true : false;
             // Create dropdown items
             $action = $archived ? 'unarchive' : 'archive';
             JHtml::_('actionsdropdown.' . $action, 'cb' . $this->rowid);
         }
         if ($config['trash']) {
             $trashed = $this->item->getFieldValue($publishedFieldName) == -2 ? true : false;
             $action = $trashed ? 'untrash' : 'trash';
             JHtml::_('actionsdropdown.' . $action, 'cb' . $this->rowid);
         }
         // Render dropdown list
         if ($config['archived'] || $config['trash']) {
             $html .= JHtml::_('actionsdropdown.render', $this->item->title);
         }
     }
     $html .= '</div>';
     return $html;
 }
All Usage Examples Of FOF30\Model\DataModel::getFieldValue