FOF30\Model\DataModel::hasField PHP Method

hasField() public method

Does this model know about a field called $fieldName? Automatically uses aliases when necessary.
public hasField ( string $fieldName ) : boolean
$fieldName string Field name to check
return boolean True if the field exists
    public function hasField($fieldName)
    {
        $realFieldName = $this->getFieldAlias($fieldName);
        return array_key_exists($realFieldName, $this->knownFields);
    }

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::hasField