Skip to content

From select with multiple option #185

@mmiraglia

Description

@mmiraglia

Hi everyone!
How can I select multiple options in a form?
In the next example I need to select "Teacher 3" and "Teacher 11" (selected attribute)
Thanks in advance!

XML form to edit a subject

	<form action="" method="post" accept-charset="utf-8">
	<input type="text" name="name" />
	<select name="year">
		<option value="1">1#</option>
		<option value="2">2#</option>
		<option value="3">3#</option>
	</select>
	<select name="teachers[]" id="teachers" multiple>
		<option value="1">T1</option>
	</select>

	<button type="submit">Save</button>
	</form>

Dump of the data

object(stdClass)[34]
  public 'subject' => 
    array (size=4)
      'id' => string '11' (length=2)
      'name' => string 'Subject 5' (length=9)
      'year' => string '2' (length=1)
      'teachers' => 
        array (size=2)
          0 => string 'Teacher 3' (length=9)
          1 => string 'Teacher 11' (length=10)
 public 'teachers' => 
    array (size=3)
      0 => 
        array (size=2)
          'id' => string '1' (length=1)
          'name' => string 'Teacher 1' (length=9)
      1 => 
        array (size=2)
          'id' => string '2' (length=1)
          'name' => string 'Teacher 3' (length=9)
      3 => 
        array (size=2)
          'id' => string '5' (length=1)
          'name' => string 'Teacher 11' (length=10)

TSS

select#teachers option {repeat: data(teachers); content: iteration(name)}
select#teachers option:attr(value) {content: iteration(id)}
form input[name="name"]:attr(value) {content: data(subject.name)}
form select[name="year"] option[value=data(subject.year)]:attr(selected) { content: 'selected'; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions