Backend\Modules\FormBuilder\Engine\Model::exists PHP Method

exists() public static method

Does the item exist.
public static exists ( integer $id ) : boolean
$id integer Id of a form.
return boolean
    public static function exists($id)
    {
        return (bool) BackendModel::getContainer()->get('database')->getVar('SELECT 1
             FROM forms AS f
             WHERE f.id = ?
             LIMIT 1', (int) $id);
    }

Usage Example

Esempio n. 1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = \SpoonFilter::getPostValue('form_id', null, '', 'int');
     $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     } else {
         // list id
         $ids = (array) explode('|', rtrim($newIdSequence, '|'));
         // loop id's and set new sequence
         foreach ($ids as $i => $id) {
             $id = (int) $id;
             // get field
             $field = BackendFormBuilderModel::getField($id);
             // from this form and not a submit button
             if (!empty($field) && $field['form_id'] == $formId && $field['type'] != 'submit') {
                 BackendFormBuilderModel::updateField($id, array('sequence' => $i + 1));
             }
         }
         $this->output(self::OK, null, 'sequence updated');
     }
 }
All Usage Examples Of Backend\Modules\FormBuilder\Engine\Model::exists