Cannon make “render_row_cb” work
-
Hello. I’ve been trying to make “render_row_cb” work, because I want to input the row and the input html myself, I cannot make it work. When I copy the example code from the documentation, it does not render the row itself, it only renders the string “cmb_test_render_row_cb”, and that’s it. Here my code.
$cmb->add_field( array( 'name' => 'Test render_row_cb (manaully rendered)', 'desc' => 'field description (optional)', 'id' => 'wiki_testrender_row_cb', 'type' => 'text', 'render_row_cb' => 'cmb_test_render_row_cb', ) ); public function cmb_test_render_row_cb( $field_args, $field ) { $id = $field->args( 'id' ); $label = $field->args( 'name' ); $name = $field->args( '_name' ); $value = $field->escaped_value(); $description = $field->args( 'description' ); ?> <div class="custom-field-row"> <p><label for="<?php echo $id; ?>"><?php echo $label; ?></label></p> <p><input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/></p> <p class="description"><?php echo $description; ?></p> </div> <?php }Now I see it says “This is mainly to edit the markup that surrounds each individual field, not to edit the field itself.”. How to edit tie fields itself? I just have a select and I want to add data attributes on each OPTION, not on the select itself, on each option.
Ex:<option value="test" data-num="1">Teest</option>
The topic ‘Cannon make “render_row_cb” work’ is closed to new replies.