AnsPress 2.0: Introducing advance form system

5.57K viewsUpdates
1

Added advance form system in AnsPress 2.0. Now it will be much easier to add new fields or modify existing form fields.
Now you can use filters to modify or add new fields.

Here is an example

    $args = array(
            'name'              => 'ask_form',
            'is_ajaxified'      => true,
            'fields'            => array(
                array(
                    'name' => 'title',
                    'label' => __('Title', 'ap'),
                    'type'  => 'text',
                    'placeholder'  => __('Question in once sentence', 'ap'),
                    'value' => sanitize_text_field(@$_POST['title'] )
                ),
                array(
                    'name' => 'category',
                    'label' => __('Category', 'ap'),
                    'type'  => 'taxonomy_select',
                    'value' => sanitize_text_field(@$_POST['category'] ),
                    'taxonomy' => 'question_category'
                ),
                array(
                    'name' => 'is_private',
                    'label' => __('Private', 'ap'),
                    'type'  => 'checkbox',
                    'desc'  => __('This question ment to be private, only visible to admin and moderator.', 'ap'),
                    'value' => sanitize_text_field(@$_POST['is_private'] )
                ),
            ),
        );
    $form = new AnsPress_Form($args);

    echo $form->get_form();

i think…it might make my work easier to extend (/ add fields into) the Ask Question form…

Yes, Indeed 🙂

0

The extendability of AnsPress is making it super powerful. This is a great start to giving a lot of customizability to the plugin 🙂

1

Nice work. We are waiting 2.0 I hope, it will come tonight. 🙂

Rahul like this or not? 😀