Configures necessary components when CRUD is in the adding mode.

@param array $fields List of fields for add form

@return void|Model If model, then bail out, no greed needed
494328
protected function configureAdd($fields = null)
    {
        // We are actually in the frame!
        if ($this->isEditing('add')) {
            $this->model->unload();
            $m = $this->form->setModel($this->model, $fields);
            $this->form->addSubmit('Add');
            $this->form->onSubmit(array($this, 'formSubmit'));

            return $m;
        } elseif ($this->isEditing()) {
            return;
        }

        // Configure Add Button on Grid and JS
        $this->add_button->js('click')->univ()
            ->frameURL(
                $this->app->_(
                    $this->entity_name === false
                    ? 'New Record'
                    : 'Adding new '.$this->entity_name
                ),
                $this->virtual_page->getURL('add'),
                $this->frame_options
            );

        if ($this->entity_name !== false) {
            $this->add_button->setIcon('plus')->setHTML('Add '.htmlspecialchars($this->entity_name));
        }
    }
406814
public function setMultiFields(array $fields = [])
    {
        if (empty($fields)) {
            unset($this->query['multi-fields']);
        } else {
            $this->query['multi-fields'] = $fields;
        }
        return $this;
    }
340015
protected function setFieldset($values)
    {
        foreach ($values as $name => $field) {
            $this->fields[$name] = $field;
        }
    }
43059
public function setFields(array $fields)
    {
        $this->checkValidLoader();

        // Flatten
        $this->loaders[ $this->contextLoader ] = [];
        $this->addFields($fields);

        return $this;
    }
927183
public function validateAsRequiredFields(array $fields) {
		foreach ($fields as $v) {
			$options = $this->fields[$v];
			$options['options']['required'] = true;
			$this->validateRequiredOneField($this->values[$v], $v, $options);
		}
	}
691193
public function includeFields(array $fields)
    {
        foreach ($fields as $fieldName) {
            $this->field($fieldName)->expression(true);
        }

        return $this;
    }
373180
public function setFields($fields) 
    {
		    if (!isset($fields['alias']) && isset($fields['tablename'])) {
            $fields['alias'] = $fields['tablename']; 
            unset($fields['tablename']);
        }

        if (!isset($fields['materialsType']) && isset($fields['typ'])) {
    		    $fields['materialsType'] = $fields['typ']; 
            unset($fields['typ']); 
        }
    
        if ($fields['type']&Catalog::LINKED) {
			try {
				$fields['prototype'] = Catalog::getById($fields['materialsType']);
				$fields['materialsType']  = $fields['prototype']->materialsType;
			} catch (\Exception $e) {
				$fields['prototype'] = Catalog::getRoot();
			}
        } else {
            $fields['prototype']    = $this;
        }
        
        parent::setFields($fields);
		$this->_catalogType   = $fields['type'];
        $this->_inheritFields = isset($fields['inheritFields'])?$fields['inheritFields']:false;
    }
216730
public function addFields(array $fields)
    {
        foreach ($fields as $name => $attrs) {
            $this->addField($name, $attrs);
        }

        return $this;
    }
1036463
public function fields(array $fields)
    {
        foreach ($fields as $field) {
            if ($field instanceof Mapper) {
                $this->addFieldFromMapper($field);
                continue;
            }
            $this->fields[] = $field;
        }

        return $this;
    }
15085
public function validate($fields = null)
    {
        $this->_di->modelsValidator->validate($this, $fields ?: $this->getChangedFields());
    }
1007106
protected function setEnvironmentFields(&$fields, $environments) {
		if(!$environments) {
			return;
		}

		$environments->getConfig()->addComponent(new GridFieldAddNewMultiClass());
		$environments->getConfig()->removeComponentsByType('GridFieldAddNewButton');
		$environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
		$environments->getConfig()->removeComponentsByType('GridFieldDeleteAction');
		$environments->getConfig()->removeComponentsByType('GridFieldPageCount');
		if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) {
			$addNewRelease = new GridFieldAddNewButton('toolbar-header-right');
			$addNewRelease->setButtonName('Add');
			$environments->getConfig()->addComponent($addNewRelease);
		}

		$fields->addFieldToTab("Root.Main", $environments);
	}
1246422
public function setFields($fields)
    {
        if ($fields instanceof RecordFields) {
            $this->fields = $fields;
        } else {
            if (is_array($fields)) {
                $fields       = new RecordFields($fields);
                $this->fields = $fields;
            }
        }
        return $this;
    }
901324
public function addRequiredFields($fields)
    {
        if (ArrayLib::is_associative($fields)) {
            
            foreach ($fields as $name => $message) {
                $this->addRequiredField($name, $message);
            }
            
        } else {
            
            foreach ($fields as $name) {
                $this->addRequiredField($name);
            }
            
        }
        
        return $this;
    }
542419
public function addDataFields($fields)
    {
        if ($this->customDataFields) {
            $this->customDataFields = array_merge($this->customDataFields, $fields);
        } else {
            $this->customDataFields = $fields;
        }
    }
733454
public function setFields($fields)
    {
        if (\is_array($fields)) {
            $fields = \implode(',', $fields);
        }

        return $this->setParam('fields', (string) $fields);
    }
1024287
public function setFields($fields = [])
    {
        $existingSchema = $this->get();

        $request = [];
        foreach ($fields as $field) {
            $mode = $this->hasField($field['name'], $existingSchema) ? 'replace-field' : 'add-field';
            $request[$mode][] = $field;
        }

        return $this->request($request);
    }
1328816
public function setFields(array $fields)
    {
        foreach ($fields as $name => $value) {
            $this->setField($name, $value);
        }

        $this->prepareQuery();

        return $this;
    }