Field related with Simple (custom defined list) in a form

[ad_1]

Without changing too much or guessing about what you’re trying to do with this form, the below modification would have the expected output:

<style>
	label { margin-bottom: 20px; }
</style>
<label>
	Colección/Serie:
	<select name="coleccion_serie" required>
		<?php
			foreach(
				(array) explode(
					PHP_EOL,
					(string) pods('libro')->fields('coleccion_serie')['pick_custom']
				) as $option
			) {
				list( $value, $label ) = explode( '|', $option );
				printf(
					'<option value="%s">%s</option>',
					esc_attr( $value ),
					esc_html( $label )
				);
			}
		?>
	</select>
</label>

If a specific option should be selected based on the selected value from a specific libro, the libro ID should be passed as the second argument to pods( 'libro', $id ) to get the value with ->field('collection_serie') (singular field, not plural fields for the full definition as used above).

To output selected="selected" for the appropriate option, see selected().

For faster methods of outputting and processing forms using Pods that doesn’t require writing your own form processor, see pods()->form() or add form="1" to a [pods] shortcode with relevant field names separated by commas in attribute fields.

It works perfect, thank you very much.

I usually use shortcodes but there are times when I also need to include the featured_images field or link to taxonomies

Till next time

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer