{"action":"created","issue":{"url":"https://api.github.com/repos/reduxframework/redux-framework/issues/2191","labels_url":"https://api.github.com/repos/reduxframework/redux-framework/issues/2191/labels{/name}","comments_url":"https://api.github.com/repos/reduxframework/redux-framework/issues/2191/comments","events_url":"https://api.github.com/repos/reduxframework/redux-framework/issues/2191/events","html_url":"https://github.com/reduxframework/redux-framework/issues/2191","id":66021598,"number":2191,"title":"How to: required for a custom field?","user":{"login":"paulthecoder","id":4132721,"avatar_url":"https://avatars.githubusercontent.com/u/4132721?v=3","gravatar_id":"","url":"https://api.github.com/users/paulthecoder","html_url":"https://github.com/paulthecoder","followers_url":"https://api.github.com/users/paulthecoder/followers","following_url":"https://api.github.com/users/paulthecoder/following{/other_user}","gists_url":"https://api.github.com/users/paulthecoder/gists{/gist_id}","starred_url":"https://api.github.com/users/paulthecoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulthecoder/subscriptions","organizations_url":"https://api.github.com/users/paulthecoder/orgs","repos_url":"https://api.github.com/users/paulthecoder/repos","events_url":"https://api.github.com/users/paulthecoder/events{/privacy}","received_events_url":"https://api.github.com/users/paulthecoder/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-02T22:14:10Z","updated_at":"2015-04-03T01:07:09Z","closed_at":"2015-04-02T22:15:54Z","body":"Redux: v 3.5\r\nWordPress: 4.1.1\r\n\r\nHey guys, I used the extension boilerplate and loader to make a custom field and everything is working great! Just wondering how I can get the \"required\" option to work. My field is basically a raw field without a table. Just like how the info field works. If anyone could just point me in the right direction, that'd be great.\r\n\r\nThanks!\r\n\r\nThe code:\r\n\r\nFile: <b>field_custom_field.php</b>\r\n```\r\n// Exit if accessed directly\r\nif( !defined( 'ABSPATH' ) ) exit;\r\n\r\n// Don't duplicate me!\r\nif( !class_exists( 'ReduxFramework_custom_field' ) ) {\r\n\r\n\t/**\r\n\t * Main ReduxFramework_custom_field class\r\n\t *\r\n\t * @since       1.0.0\r\n\t */\r\n\tclass ReduxFramework_custom_field extends ReduxFramework {\r\n\r\n\t\t/**\r\n\t\t * Field Constructor.\r\n\t\t *\r\n\t\t * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function\r\n\t\t *\r\n\t\t * @since       1.0.0\r\n\t\t * @access      public\r\n\t\t * @return      void\r\n\t\t */\r\n\t\tfunction __construct( $field = array(), $value = '', $parent ) {\r\n\r\n\r\n\t\t\t$this->parent = $parent;\r\n\t\t\t$this->field = $field;\r\n\t\t\t$this->value = $value;\r\n\r\n\t\t\tif ( empty( $this->extension_dir ) ) {\r\n\t\t\t\t$this->extension_dir = trailingslashit( str_replace( '\\\\', '/', dirname( __FILE__ ) ) );\r\n\t\t\t\t$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\\\', '/', ABSPATH ) ), '', $this->extension_dir ) );\r\n\t\t\t}\r\n\r\n\t\t\t// Set default args for this field to avoid bad indexes. Change this to anything you use.\r\n\t\t\t$defaults = array(\r\n\t\t\t\t'class'    => '',\r\n\t\t\t\t'content'  => '',\r\n\t\t\t\t'required' => array()\r\n\t\t\t);\r\n\t\t\t$this->field = wp_parse_args( $this->field, $defaults );\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * Field Render Function.\r\n\t\t *\r\n\t\t * Takes the vars and outputs the HTML for the field in the settings\r\n\t\t *\r\n\t\t * @since       1.0.0\r\n\t\t * @access      public\r\n\t\t * @return      void\r\n\t\t */\r\n\t\tpublic function render() {\r\n\r\n\t\t\techo '</td></tr></table><div id = \"' . $this->field['id'] . '\" class=\"' . $this->field['class'] . ' redux-field-' . $this->field['type'] . '\">';\r\n\r\n\t\t\t// HTML output goes here\r\n\t\t\techo $this->field['content'];\r\n\r\n\t\t\techo '</div><table class=\"form-table no-border\" style=\"margin-top: 0;\"><tbody><tr style=\"border-bottom:0; display:none;\"><th style=\"padding-top:0;\"></th><td style=\"padding-top:0;\">';\r\n\t\t}\r\n\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/reduxframework/redux-framework/issues/comments/89102743","html_url":"https://github.com/reduxframework/redux-framework/issues/2191#issuecomment-89102743","issue_url":"https://api.github.com/repos/reduxframework/redux-framework/issues/2191","id":89102743,"user":{"login":"paulthecoder","id":4132721,"avatar_url":"https://avatars.githubusercontent.com/u/4132721?v=3","gravatar_id":"","url":"https://api.github.com/users/paulthecoder","html_url":"https://github.com/paulthecoder","followers_url":"https://api.github.com/users/paulthecoder/followers","following_url":"https://api.github.com/users/paulthecoder/following{/other_user}","gists_url":"https://api.github.com/users/paulthecoder/gists{/gist_id}","starred_url":"https://api.github.com/users/paulthecoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulthecoder/subscriptions","organizations_url":"https://api.github.com/users/paulthecoder/orgs","repos_url":"https://api.github.com/users/paulthecoder/repos","events_url":"https://api.github.com/users/paulthecoder/events{/privacy}","received_events_url":"https://api.github.com/users/paulthecoder/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T01:07:09Z","updated_at":"2015-04-03T01:07:09Z","body":"Thanks for the suggestion Dovy.\r\n\r\nI ended up just using the custom field, with escaping the table. The reason is that I need pure raw HTML, instead of it being wrapped in a ```<tr>``` and ```<fieldset>``` which have their own css styles that I couldn't get rid of in a clean way. IE, the border-bottom on the ```<tr>```.\r\n\r\nIs there anything wrong with escaping the table? I just followed what the info field does.\r\n\r\nOnce again, thanks for always responding quickly and being a great help! :)"}}