Hi all :-)
I want to ask about volt. One of field in the Booking table is memberid, which is a foreign key from Member table.
My Booking controller with newAction :
public function newAction() {
$this->view->members = Member::find(); }
in Members, I already add this function :
public function __toString() { return $this->firstname . " " . $this->surname; }
I want to ask, how to use Select with volt, that show the member's name?
I already tried this :
{% for member in members %}
{{ select('fieldMemberid', members, 'using': ['id','member']) }}
{% endfor %}
but not working. The html result give the value, but not showing members name.
If I remove the ' ' sign on member, it generates error like this :
Parameter 'attribute' must be a string
0 [internal function]: Phalcon\Mvc\Model->readAttribute(Object(Tennisclub\Models\Member))
1 [internal function]: Phalcon\Tag\Select::_optionsFromResultset(Object(Phalcon\Mvc\Model\Resultset\Simple), Array, NULL, '\r\n')
2 [internal function]: Phalcon\Tag\Select::selectField(Array, NULL)
I tried without select, and it work perfect.
{% for member in members %}
{{ member }}
{% endfor %}
If I use .phtml, the working code is :
<select name="memberid" id="fieldMemberid" class="form-control"> <?php foreach ($members as $member) {echo "<option value='".$member->getID()."'>$member</option>";}?> </select>
Can somebody help me to solve this problem? Thank you so much :-)