Frontend form creates pages, select vs. pages field

I’m using the “Creating pages from frontend” cookbook example to create pages from a frontend form. Everything works fine except one thing:

If have a select field which provides URLs as a value:

<select name="seminar" id="seminar">
  <option value="" selected>– select seminar –</option>
  <?php foreach(page('seminare')->children()->listed()->filterBy('template','seminar') as $seminar): ?>
  <option value="seminar/<?= $seminar->slug() ?>"><?= $seminar->title() ?></option>
  <?php endforeach ?>
</select>

When I use a text field in the blueprint it works as expected, the field gets filled with the selected URL (“seminar/seminar-slug”).

seminar:
  label: Seminar
  type: text

But I want to use a pages field:

seminar:
  label: Seminar
  type: pages
  multiple: false
  query: site.find('seminare').children.template('seminar').listed

Although the value is exactly what the pages field would store if a page was selected in the panel (“seminar/seminar-slug”), nothing is stored when the page is created via the frontend form.

Any ideas why? Thanks!

Its not a url but an id…

But for a pages field, you have to yaml encode the id(s)

Works! Thanks, Sonja!

<?php foreach(page('seminare')->children()->listed()->filterBy('template','seminar') as $seminar): ?>
<option value="<?= Data::encode($seminar->uri(),'yaml') ?>"><?= $seminar->title() ?></option>
<?php endforeach ?>