/*
create_field()

Create the HTML interface for your field

@param	$field - an array holding all the field's data

@type	action
@since	3.6
@date	23/01/13
423506
function create_field( $field )
	{
		// require the googlemaps JS ( this script is now lazy loaded via JS )
		//wp_enqueue_script('acf-googlemaps');
		
		
		// default value
		if( !is_array($field['value']) )
		{
			$field['value'] = array();
		}
		
		$field['value'] = wp_parse_args($field['value'], array(
			'address'	=> '',
			'lat'		=> '',
			'lng'		=> ''
		));
		
		
		// default options
		foreach( $this->default_values as $k => $v )
		{
			if( ! $field[ $k ] )
			{
				$field[ $k ] = $v;
			}	
		}
		
		
		// vars
		$o = array(
			'class'		=>	'',
		);
		
		if( $field['value']['address'] )
		{
			$o['class'] = 'active';
		}
		
		
		$atts = '';
		$keys = array( 
			'data-id'	=> 'id', 
			'data-lat'	=> 'center_lat',
			'data-lng'	=> 'center_lng',
			'data-zoom'	=> 'zoom'
		);
		
		foreach( $keys as $k => $v )
		{
			$atts .= ' ' . $k . '="' . esc_attr( $field[ $v ] ) . '"';	
		}
		
		?>
		<div class="acf-google-map <?php echo $o['class']; ?>" <?php echo $atts; ?>>
			
			<div style="display:none;">
				<?php foreach( $field['value'] as $k => $v ): ?>
					<input type="hidden" class="input-<?php echo $k; ?>" name="<?php echo esc_attr($field['name']); ?>[<?php echo $k; ?>]" value="<?php echo esc_attr( $v ); ?>" />
				<?php endforeach; ?>
			</div>
			
			<div class="title">
				
				<div class="has-value">
					<a href="#" class="acf-sprite-remove ir" title="<?php _e("Clear location",'acf'); ?>">Remove</a>
					<h4><?php echo $field['value']['address']; ?></h4>
				</div>
				
				<div class="no-value">
					<a href="#" class="acf-sprite-locate ir" title="<?php _e("Find current location",'acf'); ?>">Locate</a>
					<input type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" class="search" />
				</div>
				
			</div>
			
			<div class="canvas" style="height: <?php echo $field['height']; ?>px">
				
			</div>
			
		</div>
		<?php
	}
831404
public function edit_field_add($mform) {
        // Create the form field.
        $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
        $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display!
    }
723155
public function addField(Field $field)
    {
        if (array_search($field, $this->fields) === false)
            $this->fields[] = $field;
    }
1319060
def _create_field(self, uri , name, field_type, **kwargs):
		'''
		'''
		#req sanity check
		if not (name and (field_type in ['TEXT_INPUT', 'DATE', 'PERSON'])):
			return requests.codes.bad_request, {'success' : 'False', 
												'error': 'name needs to be provided and field_type needs to be \'TEXT_INPUT\', \'DATE\' or \'PERSON\''}

		kwargs.update({'name':name, 'type':field_type})

		new_box = StreakField(**kwargs)
		#print(new_pl.attributes)
		#print(new_pl.to_dict())
		#raw_input()
		code, data = self._req('put', uri, new_box.to_dict(rw = True))
		
		return code, data
1199152
public function set_field($field) {
        global $CFG;
        if ($CFG->debugdeveloper) {
            $properties = ['id', 'shortname', 'name', 'datatype', 'description', 'descriptionformat', 'categoryid', 'sortorder',
                'required', 'locked', 'visible', 'forceunique', 'signup', 'defaultdata', 'defaultdataformat', 'param1', 'param2',
                'param3', 'param4', 'param5'];
            foreach ($properties as $property) {
                if (!property_exists($field, $property)) {
                    debugging('The \'' . $property . '\' property must be set.', DEBUG_DEVELOPER);
                }
            }
        }
        if ($this->fieldid && $this->fieldid != $field->id) {
            throw new coding_exception('Can not set field object after a different field id was set');
        }
        $this->fieldid = $field->id;
        $this->field = $field;
        $this->inputname = 'profile_field_' . $this->field->shortname;
        $this->data = $this->field->defaultdata;
        $this->dataformat = FORMAT_HTML;
    }
914078
public function addField($field, $value=null) {
        $this->fields[] = $field;
        if ($value != null) $this->set($field, $value);
    }
492104
public function field($field, $prefix = null)
    {
        if (is_array($field)) {
            $field = new Field($field);
        }

        if (! $field instanceof FieldInterface) {
            throw new Exception('Field must implement interface '.FieldInterface::class.' or be an array.');
        }

        $formField = $this->getRegistrar()->resolve($field);

        if ($prefix) {
            $formField->setPrefix($prefix);
        }

        return $formField;
    }
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);			
		
	}
666251
function create_field( $field )
	{
		// global
		global $post;
		
		
		// vars
		$args = array(
			'numberposts' => -1,
			'post_type' => null,
			'orderby' => 'title',
			'order' => 'ASC',
			'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
			'suppress_filters' => false,
		);
		
		
		// load all post types by default
		if( in_array('all', $field['post_type']) )
		{
			$field['post_type'] = apply_filters('acf/get_post_types', array());
		}
		
		
		// create tax queries
		if( ! in_array('all', $field['taxonomy']) )
		{
			// vars
			$taxonomies = array();
			$args['tax_query'] = array();
			
			foreach( $field['taxonomy'] as $v )
			{
				
				// find term (find taxonomy!)
				// $term = array( 0 => $taxonomy, 1 => $term_id )
				$term = explode(':', $v); 
				
				
				// validate
				if( !is_array($term) || !isset($term[1]) )
				{
					continue;
				}
				
				
				// add to tax array
				$taxonomies[ $term[0] ][] = $term[1];
				
			}
			
			
			// now create the tax queries
			foreach( $taxonomies as $k => $v )
			{
				$args['tax_query'][] = array(
					'taxonomy' => $k,
					'field' => 'id',
					'terms' => $v,
				);
			}
		}
		
		
		// Change Field into a select
		$field['type'] = 'select';
		$field['choices'] = array();
		
		
		foreach( $field['post_type'] as $post_type )
		{
			// set post_type
			$args['post_type'] = $post_type;
			
			
			// set order
			$get_pages = false;
			if( is_post_type_hierarchical($post_type) && !isset($args['tax_query']) )
			{
				$args['sort_column'] = 'menu_order, post_title';
				$args['sort_order'] = 'ASC';
				
				$get_pages = true;
			}
			
			
			// filters
			$args = apply_filters('acf/fields/post_object/query', $args, $field, $post);
			$args = apply_filters('acf/fields/post_object/query/name=' . $field['_name'], $args, $field, $post );
			$args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $post );
			
			
			if( $get_pages )
			{
				$posts = get_pages( $args );
			}
			else
			{
				$posts = get_posts( $args );
			}
			
			
			if($posts) {
				
				foreach( $posts as $p ) {
					
					// title
					$title = get_the_title( $p->ID );
					
					
					// empty
					if( $title === '' ) {
						
						$title = __('(no title)', 'acf');
						
					}
					
					
					// ancestors
					if( $p->post_type != 'attachment' ) {
						
						$ancestors = get_ancestors( $p->ID, $p->post_type );
						
						$title = str_repeat('- ', count($ancestors)) . $title;
						
					}
					
					
					// status
					if( get_post_status( $p->ID ) != "publish" ) {
						
						$title .= ' (' . get_post_status( $p->ID ) . ')';
						
					}
					
					
					// WPML
					if( defined('ICL_LANGUAGE_CODE') ) {
						
						$title .= ' (' . ICL_LANGUAGE_CODE . ')';
						
					}
					
					
					// filters
					$title = apply_filters('acf/fields/post_object/result', $title, $p, $field, $post);
					$title = apply_filters('acf/fields/post_object/result/name=' . $field['_name'] , $title, $p, $field, $post);
					$title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $p, $field, $post);
					
					
					// add to choices
					if( count($field['post_type']) == 1 )
					{
						$field['choices'][ $p->ID ] = $title;
					}
					else
					{
						// group by post type
						$post_type_object = get_post_type_object( $p->post_type );
						$post_type_name = $post_type_object->labels->name;
					
						$field['choices'][ $post_type_name ][ $p->ID ] = $title;
					}
					
					
				}
				// foreach( $posts as $post )
			}
			// if($posts)
		}
		// foreach( $field['post_type'] as $post_type )
		
		
		// create field
		do_action('acf/create_field', $field );
	}
1178576
public function defineAttribute($name, $field)
    {
        $field = BaseField::createField($field);

        $field->link($this, $name);

        $this->_attributes[$name] = $field;
    }
1229955
public function generateFieldID($field)
    {
        if ($form = $field->getForm()) {
            return sprintf(
                "%s_%s",
                $this->generateFormID($form),
                Convert::raw2htmlid($field->getName())
            );
        }

        return Convert::raw2htmlid($field->getName());
    }
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
	
	}
1089704
function addField(fields) {
  for (const fieldName in fields) {
    if (reservedFieldNames.indexOf(fieldName) >= 0) {
      throw new InvalidDefinitionError(this.name, 'field %s is reserved name', fieldName);
    }
    const field = Type.createField(this, fieldName, fields[fieldName]);
    if (field.props.unique && field.props.category === 'entity') {
      let unique = field.props.unique,
        message = `${fieldName} is unique`;
      if (typeof unique === 'string') message = unique;
      const index = {
        name: `${this.table}_${field.props.column}`,
        fields: [fieldName], unique: true, message,
      };
      this.indexes.push(index);
    }

    this.fields[fieldName] = field;
  }
}
1278355
public function addField($field)
    {
        if (!$field instanceof Base) {
            throw new \InvalidArgumentException(
                "No valid object passed to Fieldset::addField(). " .
                "Object should be an instance of \\ValidFormBuilder\\Base.",
                E_ERROR
            );
        }

        $this->__fields->addObject($field);

        // Set parent element hard, overwrite if previously set.
        $field->setMeta("parent", $this, true);

        if ($field->isDynamic() && get_class($field) !== "ValidFormBuilder\\MultiField"
            && get_class($field) !== "ValidFormBuilder\\Area"
        ) {
            $objHidden = new Hidden($field->getId() . "_dynamic", ValidForm::VFORM_INTEGER, array(
                "default" => 0,
                "dynamicCounter" => true
            ));

            $this->__fields->addObject($objHidden);

            $field->setDynamicCounter($objHidden);
        }
    }
158333
final public static function create( array $field, $args = array() ) {
		$field = wp_parse_args( $field, self::$defaults['field'] );
		if ( ! isset( self::$types[ $field['type'] ] )
			|| ! is_subclass_of( self::$types[ $field['type'] ], __CLASS__ )
		) {
			trigger_error(
				sprintf(
					esc_html__( '%1$s: Type %2$s is not supported, reverting to text.', 'menu-icons' ),
					__CLASS__,
					esc_html( $field['type'] )
				),
				E_USER_WARNING
			);
			$field['type'] = 'text';
		}

		if ( is_null( $field['value'] ) && ! is_null( $field['default'] ) ) {
			$field['value'] = $field['default'];
		}

		foreach ( self::$forbidden_attributes as $key ) {
			unset( $field['attributes'][ $key ] );
		}

		$args  = (object) wp_parse_args( $args, self::$defaults['args'] );
		$class = self::$types[ $field['type'] ];

		return new $class( $field, $args );
	}
865228
public function render_field_settings($field)
    {

        /*
        *  acf_render_field_setting
        *
        *  This function will create a setting for your field.
        *  Simply pass the $field parameter and an array of field settings.
        *  The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
        *
        *  More than one setting can be added by copy/paste the above code.
        *  Please note that you must also have a matching $defaults value for the field name (font_size)
        */

        // default_value
        acf_render_field_setting($field, array(
            'label' => __('Default Value', 'acf'),
            'instructions' => __('Enter each default value on a new line', 'acf'),
            'type' => 'textarea',
            'name' => 'default_value'
        ));

        // allow_null
        acf_render_field_setting($field, array(
            'label' => __('Allow Null?', 'acf'),
            'instructions' => '',
            'type' => 'radio',
            'name' => 'allow_null',
            'choices' => array(
                1 => __('Yes', 'acf'),
                0 => __('No', 'acf')
            ),
            'layout' => 'horizontal'
        ));

        // multiple
        acf_render_field_setting($field, array(
            'label'         => __('Select multiple values?','acf'),
            'instructions'  => '',
            'type'          => 'radio',
            'name'          => 'multiple',
            'choices'       => array(
                1               => __("Yes",'acf'),
                0               => __("No",'acf'),
            ),
            'layout'    =>  'horizontal',
        ));

    }
1362290
public function renderField()
    {
        list($name, $id) = $this->resolveNameID();

        TbArray::defaultValue('id', $id, $this->htmlOptions);
        TbArray::defaultValue('name', $name, $this->htmlOptions);
        $this->htmlOptions['data-url'] = $this->uploadAction;
        $this->pluginOptions['url'] = $this->uploadAction;
        if ($this->hasModel()) {
            echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);

        } else {
            echo CHtml::fileField($name, $this->value, $this->htmlOptions);
        }
    }