예제 #1
0
 /**
  * Commit the settings of this field from the section editor to
  * create an instance of this field in a section.
  *
  * @return boolean
  *  true if the commit was successful, false otherwise.
  */
 public function commit()
 {
     $fields = array();
     $fields['label'] = General::sanitize($this->get('label'));
     $fields['element_name'] = $this->get('element_name') ? $this->get('element_name') : Lang::createHandle($this->get('label'));
     $fields['parent_section'] = $this->get('parent_section');
     $fields['location'] = $this->get('location');
     $fields['required'] = $this->get('required');
     $fields['type'] = $this->_handle;
     $fields['show_column'] = $this->get('show_column');
     $fields['sortorder'] = (string) $this->get('sortorder');
     if ($id = $this->get('id')) {
         return FieldManager::edit($id, $fields);
     } else {
         if ($id = FieldManager::add($fields)) {
             $this->set('id', $id);
             $this->createTable();
             return true;
         }
     }
     return false;
 }