Creates an instance from a field controller object

@param field_controller $field
@return field_created
496042
public static function create_from_object(field_controller $field) : field_created {
        $eventparams = [
            'objectid' => $field->get('id'),
            'context'  => $field->get_handler()->get_configuration_context(),
            'other'    => [
                'shortname' => $field->get('shortname'),
                'name'      => $field->get('name')
            ]
        ];
        $event = self::create($eventparams);
        $event->add_record_snapshot($event->objecttable, $field->to_record());
        return $event;
    }
703832
public static function get_options_array(\core_customfield\field_controller $field) : array {
        if ($field->get_configdata_property('options')) {
            $options = preg_split("/\s*\n\s*/", trim($field->get_configdata_property('options')));
        } else {
            $options = array();
        }
        return array_merge([''], $options);
    }
426738
public static function factory (array $field) 
    {
        foreach (array('tag', 'occurrence', 'subfields') as $index) {
            if (!array_key_exists($index, $field)) {
                throw new InvalidArgumentException("Missing '{$index}' index in field array");
            }
        }
        return new Field($field['tag'],
                         $field['occurrence'],
                         array_map(array('HAB\Pica\Record\Subfield', 'factory'), $field['subfields']));
    }
1283352
private function cloneField(Field $field, array $overrides = [])
    {
        $fieldData = array_merge(
            [
                'id' => $field->id,
                'value' => $field->value,
                'languageCode' => $field->languageCode,
                'fieldDefIdentifier' => $field->fieldDefIdentifier,
                'fieldTypeIdentifier' => $field->fieldTypeIdentifier,
            ],
            $overrides
        );

        return new Field($fieldData);
    }
1168178
public static function delete_field_configuration(field_controller $field) : bool {
        $event = field_deleted::create_from_object($field);
        get_file_storage()->delete_area_files($field->get_handler()->get_configuration_context()->id, 'core_customfield',
            'description', $field->get('id'));
        $result = $field->delete();
        $event->trigger();
        return $result;
    }
816395
public function addField(Field $field)
    {
        $name = $field->getName();
        if (array_key_exists($name, $this->fields)) {
            throw new DuplicateFieldNameException($name);
        }
        $this->fields[$name] = $field;
        foreach ($field->getAliases() as $alias) {
            if (array_key_exists($alias, $this->fieldAliases)) {
                throw new DuplicateFieldAliasException($alias);
            }
            $this->fieldAliases[$alias] = $name;
        }

        return $this;
    }
1304277
public function removeField($field)
    {
        $field = $this->resolveAlias($field);

        unset($this->fields[$field], $this->data[$field]);

        return $this;
    }
42823
public function addField(Field $field, Key $key = null)
    {
        if (null !== $key) {
            $field->setKey($key);
        }
        
        $this->fields[$field->getName()] = $field;

        return $this;
    }
355441
public function & AddField (\MvcCore\Ext\Forms\IField $field) {
		/** @var $this \MvcCore\Ext\Forms\IForm */
		/** @var $field \MvcCore\Ext\Forms\Field */
		if ($this->dispatchState < 1) $this->Init();
		$fieldName = $field->GetName();
		$field->SetForm($this);
		$this->fields[$fieldName] = & $field;
		if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) {
			$this->submitFields[$fieldName] = & $field;
			$fieldCustomResultState = $field->GetCustomResultState();
			if ($fieldCustomResultState !== NULL)
				$this->customResultStates[$fieldName] = $fieldCustomResultState;
		}
		return $this;
	}
189727
public static function createFromField(Field $field): self
    {
        $message = new self();
        $message->setId($field->getId());
        $message->setToken($field->getToken());
        $message->setDescription($field->getDescription());

        foreach ($field->getTranslations() as $translation) {
            $transMessage = FieldTranslationMessage::createFromFieldTranslation($translation);

            $message->addTranslation($transMessage);
        }

        return $message;
    }
901866
public function filterFields(FieldBag $fields)
    {
        $allFields = $this->getModule()->getOption('model_fields');

        $filteredFields = new FieldBag();
        foreach ($fields as $name => $field) {
            if (!$allFields->has($name)) {
                throw new \RuntimeException(sprintf('The field "%s" does not exist.', $name));
            }

            $filteredField = clone $field;
            foreach ($allFields->get($name)->getOptions() as $optionName => $optionValue) {
                if (!$filteredField->hasOption($optionName)) {
                    $filteredField->setOption($optionName, $optionValue);
                }
            }

            $filteredFields->set($name, $filteredField);
        }

        return $filteredFields;
    }
593303
protected function getNewHelper(Field $field)
    {
        $stub = $this->getStubContent('form-helper-field.blade', $this->template);

        $this->replaceFieldName($stub, $field->name);

        return $stub;
    }
318581
public function pushField(Field $field)
    {
        $field = $this->formatField($field);

        $this->fields->push($field);

        return $this;
    }
1116439
function create_field( $field )
	{
		if( ! function_exists( 'get_editable_roles' ) )
		{ 
			// if using front-end forms then we need to add this core file
			require_once( ABSPATH . '/wp-admin/includes/user.php' ); 
		}
		
		// options
   		$options = array(
			'post_id' => get_the_ID(),
		);
		
		
		// vars
		$args = array();
		
		
		// editable roles
		$editable_roles = get_editable_roles();
		
		if( !empty($field['role']) )
		{
			if( ! in_array('all', $field['role']) )
			{
				foreach( $editable_roles as $role => $role_info )
				{
					if( !in_array($role, $field['role']) )
					{
						unset( $editable_roles[ $role ] );
					}
				}
			}
			
		}
		
		// filters
		$args = apply_filters('acf/fields/user/query', $args, $field, $options['post_id']);
		$args = apply_filters('acf/fields/user/query/name=' . $field['_name'], $args, $field, $options['post_id'] );
		$args = apply_filters('acf/fields/user/query/key=' . $field['key'], $args, $field, $options['post_id'] );
		
		
		// get users
		$users = get_users( $args );
		
		
		if( !empty($users) && !empty($editable_roles) )
		{
			$field['choices'] = array();
			
			foreach( $editable_roles as $role => $role_info )
			{
				// vars
				$this_users = array();
				$this_json = array();
				
				
				// loop over users
				$keys = array_keys($users);
				foreach( $keys as $key )
				{
					if( in_array($role, $users[ $key ]->roles) )
					{
						$this_users[] = $users[ $key ];
						unset( $users[ $key ] );
					}
				}
				
				
				// bail early if no users for this role
				if( empty($this_users) )
				{
					continue;
				}
				
				
				// label
				$label = translate_user_role( $role_info['name'] );
				
				
				// append to choices
				$field['choices'][ $label ] = array();
				
				foreach( $this_users as $user )
				{
					$field['choices'][ $label ][ $user->ID ] = ucfirst( $user->display_name );
				}
				
			}
		}
		
		
		// modify field
		if( $field['field_type'] == 'multi_select' )
		{
			$field['multiple'] = 1;
		}
		
		
		$field['type'] = 'select';
		
		
		do_action('acf/create_field', $field);			
		
	}
2431
function create_field( $field )
	{
		// vars
		$single_name = $field['name'];
			
			
		// multi select?
		if( $field['field_type'] == 'multi_select' )
		{
			$field['multiple'] = 1;
			$field['field_type'] = 'select';
			$field['name'] .= '[]';
		}
		elseif( $field['field_type'] == 'checkbox' )
		{
			$field['name'] .= '[]';
		}
		
		// value must be array!
		if( !is_array($field['value']) )
		{
			$field['value'] = array( $field['value'] );
		}
		
		
		// vars
		$args = array(
			'taxonomy'     => $field['taxonomy'],
			'hide_empty'   => false,
			'style'        => 'none',
			'walker'       => new acf_taxonomy_field_walker( $field ),
		);
		
		$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field );
		
		?>
<div class="acf-taxonomy-field" data-load_save="<?php echo $field['load_save_terms']; ?>">
	<input type="hidden" name="<?php echo $single_name; ?>" value="" />
	
	<?php if( $field['field_type'] == 'select' ): ?>
		
		<select id="<?php echo $field['id']; ?>" name="<?php echo $field['name']; ?>" <?php if( $field['multiple'] ): ?>multiple="multiple" size="5"<?php endif; ?>>
			<?php if( $field['allow_null'] ): ?>
				<option value=""><?php _e("None", 'acf'); ?></option>
			<?php endif; ?>
	
	<?php else: ?>
		<div class="categorychecklist-holder">
		<ul class="acf-checkbox-list">
			<?php if( $field['allow_null'] ): ?>
				<li>
					<label class="selectit">
						<input type="<?php echo $field['field_type']; ?>" name="<?php echo $field['name']; ?>" value="" /> <?php _e("None", 'acf'); ?>
					</label>
				</li>
			<?php endif; ?>
	
	<?php endif; ?>
			
			<?php wp_list_categories( $args ); ?>
	
	<?php if( $field['field_type'] == 'select' ): ?>
	
		</select>
	
	<?php else: ?>
	
		</ul>
		</div>
		
	<?php endif; ?>

</div>
	<?php
	
	}
948459
def _field_controller_generator(self):
        
        # Local variable, to avoid messing with "self"
        stored_instance = self._ipopo_instance

        def get_value(self, name):
            # pylint: disable=W0613
            """
            Retrieves the controller value, from the iPOPO dictionaries

            :param name: The property name
            :return: The property value
            """
            return stored_instance.get_controller_state(name)

        def set_value(self, name, new_value):
            # pylint: disable=W0613
            """
            Sets the property value and trigger an update event

            :param name: The property name
            :param new_value: The new property value
            """
            # Get the previous value
            old_value = stored_instance.get_controller_state(name)
            if new_value != old_value:
                # Update the controller state
                stored_instance.set_controller_state(name, new_value)

            return new_value

        return get_value, set_value
182495
public function addField(Field $field, $key = null)
    {
        $this->fields[$key] = $field;

        return $this;
    }