0

I have the following function in my plugin and want to add the Datepicker and Textarea dynamically, so that the User can add an row of the same Elements with an "Add" button. I have an array with register_setting but i don't know how I implement the rest.

function test_plugin_settings_page() { ?>
    <div class="wrap">
        <h2>Test Plugin</h2>
        <form method="post" action="options.php">
            <?php settings_fields( 'test-plugin-settings-group' ); ?>
            <?php do_settings_sections( 'test-plugin-settings-group' ); ?>

            <table class="form-table">
                <tr valign="top">
                    <td> Datum: </td>
                    <td><input type="text" class="datepick" name="test_plugin_datepicker" value="<?php echo get_option( 'test_plugin_datepicker' ); ?>"/></td>
                    <td> Beschreibung:  </td>
                    <td><textarea id='test_plugin_descr' name='test_plugin_descr' rows='1' cols='30' type='textarea'><?php echo get_option( 'test_plugin_descr' ); ?></textarea></td>
                </tr>
            </table>
            <?php submit_button(); ?>
        </form>
    </div>

    <?php } 
  • 1
    you're going to need to use javascript/jquery to add them dynamically. to get the PHP to handle the inputs you'll want to add [] to the end of the input names. this will get you an array of values in $_POST['input_name'] on submit – mrben522 Dec 17 '18 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.