Coder Social home page Coder Social logo

acf-field-type-template's People

Contributors

beaucharman avatar binarykitten avatar davidshq avatar dboulet avatar elliotcondon avatar lgladdy avatar mattgrshaw avatar shaunbent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acf-field-type-template's Issues

Warning: Use of undefined constant load_plugin_acf

Hi! I have followed the search-and-replace naming instructions on https://www.advancedcustomfields.com/resources/creating-a-new-field-type/ but on plugin activation WordPress breaks and I get these errors:


Warning: Use of undefined constant load_plugin_acf - assumed 'load_plugin_acf' (this will throw an Error in a future version of PHP) in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php on line 77

Warning: Use of undefined constant cca - assumed 'cca' (this will throw an Error in a future version of PHP) in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php on line 77

Warning: A non-numeric value encountered in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php on line 77 Warning: A non-numeric value encountered in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php on line 77

Fatal error: Uncaught Error: Call to undefined function categories() in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php:77 Stack trace: #0 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/class-wp-hook.php(286): creativecircle_acf_plugin_cca_categories->include_field(5) #1 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/advanced-custom-fields-pro/acf.php(300): do_action('acf/include_fie...', 5) #4 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/class-wp-hook.php(286): ACF->init('') #5 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #6 /customers/9/9/7/creativecircle.dk/httpd.www/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #7 /customers in /customers/9/9/7/creativecircle.dk/httpd.www/wp-content/plugins/acf-cca-categories/acf-cca-categories.php on line 77


I have gone through all files and the search-and-replace naming is correct everywhere as per the instructions.

Do you have an idea if this could be an incompatability error for the WordPress version (5.0.3 installed)? Or any idea what could be wrong?

I have replaced placeholders with these:
NAMESPACE: creativecircle
FIELD_NAME: cca_categories
FIELD-NAME: cca-categories
FIELD_LABEL: CCA categories
TEXTDOMAIN: acf-cca-categories

input_admin_enqueue_scripts uses wrong path

Enabling input_admin_enqueue_scripts in acf-service-icon-v5.php tries to enqueue scrips and stylesheets from the wrong directory.

It looks like a28f496 moved css and js assets into assets/ and the two acf-FIELD_NAME-v#.php files into fields/, but overlooked the line generating $dir in this function. This results in attempts to load scripts from fields/css/ and fields/js/ instead of assets/.

I patched this by changing $dir here, but my project doesn't need to worry about older PHP versions, and I don't have a sense of the project's coding style yet, so I didn't submit a PR.

from:

    $dir = plugin_dir_url( __FILE__ );

to

    $dir = plugin_dir_url( __DIR__ ) . 'assets/';

Plugin could not be activated because it triggered a fatal error.

I am unable to install this plugin in my wordpress( i am running locally). Its throws an error.

Parse error: syntax error, unexpected '{', expecting T_FUNCTION in C:\wamp\www\wordpress-3.6.1\wordpress\wp-content\plugins\acf-field-type-template-master\acf-{{field_name}}.php on line 14
Call Stack

Conditionals in Main file

Hey E,

I wondering if you can add some conditionals in the main file acf-FIELD_NAME.php. I'm attempting to use someone add on in another plugin and I'm having an issue with duplicate functions.

Something like below, or however you'd prefer to do it. This would help for plugins created in the future.

Thanks,

~JH

<?php

/*
Plugin Name: Advanced Custom Fields: FIELD_LABEL
Plugin URI: PLUGIN_URL
Description: SHORT_DESCRIPTION
Version: 1.0.0
Author: AUTHOR_NAME
Author URI: AUTHOR_URL
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/


// add conditional loading
if (!function_exists('include_field_types_FIELD_NAME')):


// 1. set text domain
// Reference: https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
load_plugin_textdomain( 'acf-FIELD_NAME', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); 




// 2. Include field type for ACF5
// $version = 5 and can be ignored until ACF6 exists
function include_field_types_FIELD_NAME( $version ) {

    include_once('acf-FIELD_NAME-v5.php');

}

add_action('acf/include_field_types', 'include_field_types_FIELD_NAME');    




// 3. Include field type for ACF4
function register_fields_FIELD_NAME() {

    include_once('acf-FIELD_NAME-v4.php');

}

add_action('acf/register_fields', 'register_fields_FIELD_NAME');    

endif;


?>

Field not displaying

Hello there

I installed the default FIELD_NAME placeholder setup you guys have here. It worked, so then I moved on to naming everything with the names I wanted. I have also removed support for v4(it's going to be an internal plugin so v5 is all we need). That being said, the few tweaks I have made now remove the field from the options list. I've been going through this code piece by piece, but I could use a second pair of eyes to help me out.

acf-deevy-checkbox.php

<?php

/*
Plugin Name: Advanced Custom Fields: Deevy Checkbox
Plugin URI: https://beesney.com
Description: Textarea checkbox
Version: 1.0.0
Author: Andrew
Author URI: https://deevycreative.com
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/

// exit if accessed directly
if( ! defined( 'ABSPATH' ) ) exit;


// check if class already exists
if( !class_exists('acf_plugin_deevy_checkbox') ) :

class acf_plugin_deevy_checkbox {
	
	// vars
	var $settings;
	
	
	/*
	*  __construct
	*
	*  This function will setup the class functionality
	*
	*  @type	function
	*  @date	17/02/2016
	*  @since	1.0.0
	*
	*  @param	n/a
	*  @return	n/a
	*/
	
	function __construct() {
		
		// settings
		// - these will be passed into the field class.
		$this->settings = array(
			'version'	=> '1.0.0',
			'url'		=> plugin_dir_url( __FILE__ ),
			'path'		=> plugin_dir_path( __FILE__ )
		);
		
		
		// set text domain
		// https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
		load_plugin_textdomain( 'acf-deevy-checkbox', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); 
		
		
		// include field
		add_action('acf/include_field_types', 	array($this, 'include_field_types')); // v5
		
	}
	
	
	/*
	*  include_field_types
	*
	*  This function will include the field type class
	*
	*  @type	function
	*  @date	17/02/2016
	*  @since	1.0.0
	*
	*  @param	$version (int) major ACF version. Defaults to false
	*  @return	n/a
	*/
	
	function include_field_types( $version = false ) {
		
		// support empty $version
		if( !$version ) $version = 4;
		
		
		// include
		include_once('fields/class-deevy-acf-field-deevy-checkbox-v' . $version . '.php');
		
	}
	
}


// initialize
new acf_plugin_deevy_checkbox();


// class_exists check
endif;
	
?>

fields/class-deevy-acf-field-deevy-checkbox-v5.php

<?php

// exit if accessed directly
if( ! defined( 'ABSPATH' ) ) exit;


// check if class already exists
if( !class_exists('acf_plugin_deevy_checkbox') ) :


class acf_plugin_deevy_checkbox extends acf_field {
	
	
	/*
	*  __construct
	*
	*  This function will setup the field type data
	*
	*  @type	function
	*  @date	5/03/2014
	*  @since	5.0.0
	*
	*  @param	n/a
	*  @return	n/a
	*/
	
	function __construct( $settings ) {
		
		/*
		*  name (string) Single word, no spaces. Underscores allowed
		*/
		
		$this->name = 'deevy_checkbox';
		
		
		/*
		*  label (string) Multiple words, can include spaces, visible when selecting a field type
		*/
		
		$this->label = __('Deevy Checkbox', 'acf-deevy-checkbox');
		
		
		/*
		*  category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME
		*/
		
		$this->category = 'choice';
		
		
		/*
		*  defaults (array) Array of default settings which are merged into the field object. These are used later in settings
		*/
		
		$this->defaults = array(
			'font_size'	=> 14,
		);
		
		
		/*
		*  l10n (array) Array of strings that are used in JavaScript. This allows JS strings to be translated in PHP and loaded via:
		*  var message = acf._e('FIELD_NAME', 'error');
		*/
		
		$this->l10n = array(
			'error'	=> __('Error! Please enter a higher value', 'acf-deevy-checkbox'),
		);
		
		
		/*
		*  settings (array) Store plugin settings (url, path, version) as a reference for later use with assets
		*/
		
		$this->settings = $settings;
		
		
		// do not delete!
    	parent::__construct();
    	
	}
	
	
	/*
	*  render_field_settings()
	*
	*  Create extra settings for your field. These are visible when editing a field
	*
	*  @type	action
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$field (array) the $field being edited
	*  @return	n/a
	*/
	
	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)
		*/
		
		acf_render_field_setting( $field, array(
			'label'			=> __('Font Size','acf-deevy-checkbox'),
			'instructions'	=> __('Customise the input font size','acf-deevy-checkbox'),
			'type'			=> 'number',
			'name'			=> 'font_size',
			'prepend'		=> 'px',
		));

	}
	
	
	
	/*
	*  render_field()
	*
	*  Create the HTML interface for your field
	*
	*  @param	$field (array) the $field being rendered
	*
	*  @type	action
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$field (array) the $field being edited
	*  @return	n/a
	*/
	
	function render_field( $field ) {
		
		
		/*
		*  Review the data of $field.
		*  This will show what data is available
		*/
		
		echo '<pre>';
			print_r( $field );
		echo '</pre>';
		
		
		/*
		*  Create a simple text input using the 'font_size' setting.
		*/
		
		?>
		<input type="text" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>" style="font-size:<?php echo $field['font_size'] ?>px;" />
		<?php
	}
	
		
	/*
	*  input_admin_enqueue_scripts()
	*
	*  This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
	*  Use this action to add CSS + JavaScript to assist your render_field() action.
	*
	*  @type	action (admin_enqueue_scripts)
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	n/a
	*  @return	n/a
	*/

	/*
	
	function input_admin_enqueue_scripts() {
		
		// vars
		$url = $this->settings['url'];
		$version = $this->settings['version'];
		
		
		// register & include JS
		wp_register_script('TEXTDOMAIN', "{$url}assets/js/input.js", array('acf-input'), $version);
		wp_enqueue_script('TEXTDOMAIN');
		
		
		// register & include CSS
		wp_register_style('TEXTDOMAIN', "{$url}assets/css/input.css", array('acf-input'), $version);
		wp_enqueue_style('TEXTDOMAIN');
		
	}
	
	*/
	
	
	/*
	*  input_admin_head()
	*
	*  This action is called in the admin_head action on the edit screen where your field is created.
	*  Use this action to add CSS and JavaScript to assist your render_field() action.
	*
	*  @type	action (admin_head)
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	n/a
	*  @return	n/a
	*/

	/*
		
	function input_admin_head() {
	
		
		
	}
	
	*/
	
	
	/*
   	*  input_form_data()
   	*
   	*  This function is called once on the 'input' page between the head and footer
   	*  There are 2 situations where ACF did not load during the 'acf/input_admin_enqueue_scripts' and 
   	*  'acf/input_admin_head' actions because ACF did not know it was going to be used. These situations are
   	*  seen on comments / user edit forms on the front end. This function will always be called, and includes
   	*  $args that related to the current screen such as $args['post_id']
   	*
   	*  @type	function
   	*  @date	6/03/2014
   	*  @since	5.0.0
   	*
   	*  @param	$args (array)
   	*  @return	n/a
   	*/
   	
   	/*
   	
   	function input_form_data( $args ) {
	   	
		
	
   	}
   	
   	*/
	
	
	/*
	*  input_admin_footer()
	*
	*  This action is called in the admin_footer action on the edit screen where your field is created.
	*  Use this action to add CSS and JavaScript to assist your render_field() action.
	*
	*  @type	action (admin_footer)
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	n/a
	*  @return	n/a
	*/

	/*
		
	function input_admin_footer() {
	
		
		
	}
	
	*/
	
	
	/*
	*  field_group_admin_enqueue_scripts()
	*
	*  This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited.
	*  Use this action to add CSS + JavaScript to assist your render_field_options() action.
	*
	*  @type	action (admin_enqueue_scripts)
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	n/a
	*  @return	n/a
	*/

	/*
	
	function field_group_admin_enqueue_scripts() {
		
	}
	
	*/

	
	/*
	*  field_group_admin_head()
	*
	*  This action is called in the admin_head action on the edit screen where your field is edited.
	*  Use this action to add CSS and JavaScript to assist your render_field_options() action.
	*
	*  @type	action (admin_head)
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	n/a
	*  @return	n/a
	*/

	/*
	
	function field_group_admin_head() {
	
	}
	
	*/


	/*
	*  load_value()
	*
	*  This filter is applied to the $value after it is loaded from the db
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value (mixed) the value found in the database
	*  @param	$post_id (mixed) the $post_id from which the value was loaded
	*  @param	$field (array) the field array holding all the field options
	*  @return	$value
	*/
	
	/*
	
	function load_value( $value, $post_id, $field ) {
		
		return $value;
		
	}
	
	*/
	
	
	/*
	*  update_value()
	*
	*  This filter is applied to the $value before it is saved in the db
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value (mixed) the value found in the database
	*  @param	$post_id (mixed) the $post_id from which the value was loaded
	*  @param	$field (array) the field array holding all the field options
	*  @return	$value
	*/
	
	/*
	
	function update_value( $value, $post_id, $field ) {
		
		return $value;
		
	}
	
	*/
	
	
	/*
	*  format_value()
	*
	*  This filter is appied to the $value after it is loaded from the db and before it is returned to the template
	*
	*  @type	filter
	*  @since	3.6
	*  @date	23/01/13
	*
	*  @param	$value (mixed) the value which was loaded from the database
	*  @param	$post_id (mixed) the $post_id from which the value was loaded
	*  @param	$field (array) the field array holding all the field options
	*
	*  @return	$value (mixed) the modified value
	*/
		
	/*
	
	function format_value( $value, $post_id, $field ) {
		
		// bail early if no value
		if( empty($value) ) {
		
			return $value;
			
		}
		
		
		// apply setting
		if( $field['font_size'] > 12 ) { 
			
			// format the value
			// $value = 'something';
		
		}
		
		
		// return
		return $value;
	}
	
	*/
	
	
	/*
	*  validate_value()
	*
	*  This filter is used to perform validation on the value prior to saving.
	*  All values are validated regardless of the field's required setting. This allows you to validate and return
	*  messages to the user if the value is not correct
	*
	*  @type	filter
	*  @date	11/02/2014
	*  @since	5.0.0
	*
	*  @param	$valid (boolean) validation status based on the value and the field's required setting
	*  @param	$value (mixed) the $_POST value
	*  @param	$field (array) the field array holding all the field options
	*  @param	$input (string) the corresponding input name for $_POST value
	*  @return	$valid
	*/
	
	/*
	
	function validate_value( $valid, $value, $field, $input ){
		
		// Basic usage
		if( $value < $field['custom_minimum_setting'] )
		{
			$valid = false;
		}
		
		
		// Advanced usage
		if( $value < $field['custom_minimum_setting'] )
		{
			$valid = __('The value is too little!','TEXTDOMAIN'),
		}
		
		
		// return
		return $valid;
		
	}
	
	*/
	
	
	/*
	*  delete_value()
	*
	*  This action is fired after a value has been deleted from the db.
	*  Please note that saving a blank value is treated as an update, not a delete
	*
	*  @type	action
	*  @date	6/03/2014
	*  @since	5.0.0
	*
	*  @param	$post_id (mixed) the $post_id from which the value was deleted
	*  @param	$key (string) the $meta_key which the value was deleted
	*  @return	n/a
	*/
	
	/*
	
	function delete_value( $post_id, $key ) {
		
		
		
	}
	
	*/
	
	
	/*
	*  load_field()
	*
	*  This filter is applied to the $field after it is loaded from the database
	*
	*  @type	filter
	*  @date	23/01/2013
	*  @since	3.6.0	
	*
	*  @param	$field (array) the field array holding all the field options
	*  @return	$field
	*/
	
	/*
	
	function load_field( $field ) {
		
		return $field;
		
	}	
	
	*/
	
	
	/*
	*  update_field()
	*
	*  This filter is applied to the $field before it is saved to the database
	*
	*  @type	filter
	*  @date	23/01/2013
	*  @since	3.6.0
	*
	*  @param	$field (array) the field array holding all the field options
	*  @return	$field
	*/
	
	/*
	
	function update_field( $field ) {
		
		return $field;
		
	}	
	
	*/
	
	
	/*
	*  delete_field()
	*
	*  This action is fired after a field is deleted from the database
	*
	*  @type	action
	*  @date	11/02/2014
	*  @since	5.0.0
	*
	*  @param	$field (array) the field array holding all the field options
	*  @return	n/a
	*/
	
	/*
	
	function delete_field( $field ) {
		
		
		
	}	
	
	*/
	
	
}


// initialize
new acf_plugin_deevy_checkbox( $this->settings );


// class_exists check
endif;

?>

The v4 file has been removed.

Does anything jump out here as to why the code would not be rendering the field in the options list?

Thanks!

v4: Include failed

Warning: include_once(): Failed opening 'fields/acf-quiz_answer-v.php' for inclusion

$version is never passed to function via 'acf/register_fields' action

JS field extend error after version 5.6.5

I'm having a custom field type that extending the select field. This is my initialize_field function:

function initialize_field( $field ) {

    acf.fields.department = acf.fields.select.extend({

        type: 'department'

    });

}

After upgrading to version 5.7.2 I got an JS error when the field is displaying in the back-end:
input.js:20 Uncaught TypeError: Cannot read property 'extend' of undefined

When I'm looking at the acf object in the console log, looks like this object has been changed in the new version and there's no fields property in this object anymore. Anyone know is there a way to extend the select field in the latest version of ACF?

Thanks,
Minh

adding support default value

How do you add support for the default value option on v5?

BTW: Sorry for the noob questing but couldn't find any information about this voor version 5

Missing semicolon

hey Elliot, long time..

I was just fixing one of my addons acf-sites for ACF 5.. great update btw!
Anyway, I came by an error in your template.. inside function format_value you lack a semicolon after return $value on row 377!

Easy fix but I don't have time to do a fork atm :)

update_value not firing if value is null

I am trying to fix the "allow_multiple" and "allow_null" options that the Gravity Forms field_type (https://github.com/stormuk/Gravity-Forms-ACF-Field) adds.

The following is assuming I have set "allow_null" to false and "allow_multiple" to true.

When selecting multiple values for a multi-select everything works the way it should. To note, the plugin does not define update_values function. When de-selecting all options and submitting the database is not updated.

I have added in the update_values function to the plugin and it fires properly when selecting options but if I de-select all options and save the update_values function is skipped. I am trying to get the select to act just like the select in ACF where when de-selecting everything saves a null value to the DB.

Am I missing something? Also to note, I made sure to add the brackets "[]" to the end of the field name when "allow_multiple" is set to true.

TypeError: acf.add_action is not a function

Hi Elliot,
Kudos! A great option to create custom field types to an already superb plugin; ACF :)

For some reason, the function "add_action" is missing from the object acf when the page loads (with the new custom field). Do you know what the problem might be?

Thanks in advance

Rename placeholder DESCRIPTION or put after EXTENDED_DESCRIPTION

Thanks for this great template making it ultra fast to create new field types!

The following is a minor issue.

When I do a search and replace for the various placeholders as recommended in the documentation I always run into a conflict between the DESCRIPTION and EXTENDED_DESCRIPTION due to the order they appear in:

When you search and replace DESCRIPTION you also target the DESCRIPTION-part of the EXTENDED_DESCRIPTION-placeholders resulting in weird extended descriptions like

"EXTENDED_Provides a field type that makes ACF even more awesome."

A simple solution could be to use SHORT_DESCRIPTION as placeholder for the description field to avoid the conflict. Or simply swap the order of the two in the documentation, so that most users will target the extended description first.

Wrong placeholder DESCRIPTION

I think the placeholder "DESCRIPTION" described in the Documentation "Creating a new field type" is actually "SHORT_DESCRIPTION".
Below, a screenshot of Phpstorm's Find & Replace functionnality:

image

ACF5 - Validation is not working.

I have searched and searched & can't find any examples of implementing validation on new fields. I'm assuming I'm doing it right, but it's not working.

Problem:

  • When I mark my new_field required.
  • The form submits when new_field is empty.
  • No errors are triggered.

Here's the code I added to the acf-new_field-v5.php file under method: validate_value()

function validate_value( $valid, $value, $field, $input ){
        /*
        if( !$valid ) {

            return $valid;

        }

        $level_2 = $field['acf']['field_5390f057f0928']['level_2'];

        if( $level_2 != 'TESTING' || empty($level_2) ) {

            $valid = 'Service is required.';

        }
*/
        $valid = __('Service is required.','acf-new_field');
        // return
        return $valid;

    }

Any help would be appreciated. Notice I stripped out all my testing code & just set the function to return invalid always, but that doesn't even work. That makes me think I must be doing something wrong.

syntax error, unexpected '{',

Parse error: syntax error, unexpected '{', expecting T_FUNCTION in D:\WebServer\www\aw3\aw3\wp-content\plugins\acf-field-type-template-master\acf-{{field_name}}.php on line 14

Readme files show EXTENDED_DESCRIPTION

I was just reading the Readme file and found it saying EXTENDED_DESCRIPTION, does this have a general purpose or is it a placeholder for something not yet written?

ACF V5 Template - input_admin_enqueue_scripts not being called.

I am using the template thank you for making it so easy.

I replaced all the keyword (FIELD_NAME ...) with my plugin name and so on. All field are saving but for some reason my scripts/css are not being included on the page.

I am using "input_admin_enqueue_scripts" in the template like so, do i need and action? I thought input_admin_enqueue_scripts like render_field and so on. Any help would be great.

function input_admin_enqueue_scripts() {

		// vars
		$url 			= $this->settings['url'];
		$version  = $this->settings['version'];

		// register & include JS
		wp_register_script('instagrame-admin-script', "{$url}assets/js/input.js", array( 'acf-input'), $version);
		wp_enqueue_script('instagrame-admin-script');


		wp_register_script('instagrame-admin-spectragram-script', "{$url}assets/js/input.js", array('jquery', 'acf-input'), $version);
		wp_enqueue_script('instagrame-admin-spectragram-script');


		// register & include CSS
		wp_register_style('instagrame-admin-css', "{$url}assets/css/input.css", array('acf-input'), $version);
		wp_enqueue_style('instagrame-admin-css');

	}

here is my repo
https://github.com/wightspace/acf-instagram

J

How to use input.js?

Hi Elliot,

How can my code work. I've tried but they all do not work.
(Sorry, my english isn't good!)

Thank so much!

Value always false in repeater

When I try to embed a custom field type in to a repeater it always returns false as it's value. Is there anything beyond what is in the sample files that needs to be done to support embedding within a repeater?

js/input.js: Repeater field and jQuery

The following doesn't work in a repeater field:

    $(document).live('acf/setup_fields', function(e, postbox){
        $(postbox).find('.time_picker').each(function(){

This does:

    $(function() {
        $(".field").on("focusin", "input[type=text].time_picker",  function(){

Functions not hooking in v4.x

Can it be that due to several updates this plugin is not fully working with ACF v4.x anymore ?

I can't get load_value and update_value to run in this template, as explained in this topic.

wrong echo output

Hello I hope u can help me=)

If I'm doing something like that:

echo (
	        '$body-color:'. the_field("background_color", "option")

    );

my output is:
#c614c9$body-color:

what to do, get it in the right order like that?
$body-color: #c614c9

In {{field_name}}-v3.php, create_options do_action() should be $this->parent->create_field()

Replace

do_action('acf/create_field', array(
    'type'      =>  'radio',
    'name'      =>  'fields['.$key.'][preview_size]',
    'value'     =>  $field['preview_size'],
    'layout'    =>  'horizontal',
    'choices'   =>  array(
        'thumbnail' => __('Thumbnail'),
        'something_else' => __('Something Else'),
    )
));

With

$this->parent->create_field(array(
    'type'      =>  'radio',
    'name'      =>  'fields['.$key.'][preview_size]',
    'value'     =>  $field['preview_size'],
    'layout'    =>  'horizontal',
    'choices'   =>  array(
        'thumbnail' => __('Thumbnail'),
        'something_else' => __('Something Else'),
    )
));

Paths to JS & CSS files are incorrect

The paths to the assets folder is incorrect.

$dir = plugin_dir_url( __FILE__ );
// this is the path to the folder "fields" and the "assets" folder is adjacent sibling to "fields"

wp_register_script( 'acf-input-addb', "{$dir}assets/js/input.js" );

I suspect that the issue applies to both v4 and v5 (I am using v5)

ACF pro (v5)

Hi.
Just letting you know that this doesn't work in acf pro or v5.
-R

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.