[Flow] Validate an object from <f:form.select>

Mark Kuiphuis typo3 at markyourweb.com
Sun Jun 2 06:47:48 CEST 2013


Hi all,

The subject of this message might look a bit strange, as I didn't know 
how to name it :D

How and where do I check the existence of an object which should be 
selected from a <select> upon saving this object.

I would like to have something like this.

<select name="room">
<option value=""> Please select a room<option>
<option value="52b00343-5fe6-df19-cdf9-8e2258dfc0a7"> Room 1 <option>
<option value="3c965a1f-1a11-e6d5-26f1-393ece3a5e41"> Room 2 <option>
<option value="f2a1b211-6504-713c-e155-2f8c08f2652e"> Room 3 <option>
</select>

When, for example, creating a lecture, I need to assign that lecture to 
a room. I have already created these rooms and these rooms can be 
selected from a <select> drop down field.

Instead of leaving the first option out and have the lecture always been 
added to first room in the list (because people forget to select the 
correct room and as such the lecture is saved with the incorrect room), 
I would like to show an error message when they try to save the lecture, 
whilst they haven't selected the room, similar to the error message when 
for example the title hasn't been filled in.

I couldn't find a suitable Validator in Flow which might be able to do 
this. I'm using Flow 2.0 Beta BTW...

I'm probably overlooking something, but don't know what :-)

The Lecture model does have this property:

/**
  * The room
  * @var \My\Package\Domain\Model\Room
  * @ORM\ManyToOne(inversedBy="lectures")
  */
  protected $room;

/**
  * Sets this Lecture's room
  *
  * @param \My\Package\Domain\Model\Room $room The lecture's room
  * @return void
  */
public function setRoom(\My\Package\Domain\Model\Room $room) {
	$this->room = $room;
}

I tried to add a @Flow\Validate(type="NotEmpty") but that doesn't work.

Thanks in advance,

Mark Kuiphuis


More information about the Flow mailing list