E 'possibile aggiungere uno <option>
alla fine di uno <select>
creato con il metodo helper collection_select
?Il metodo helper collection_select di Rails e l'opzione "Create item" alla fine
In questo momento ho
f.collection_select(:category_id , @categories, :id, :name, {:prompt => 'Please select a category'})
che genera
<select id="product_category_id" name="product[category_id]">
<option value="">Please select a category</option>
<option value="7">category one</option>
<option value="8">category 2</option>
</select>
e quello che vorrei è
<select id="product_category_id" name="product[category_id]">
<option value="">Please select a category</option>
<option value="7">category one</option>
<option value="8">category 2</option>
<option value="new">..or create a new one</option>
</select>
Questo è possibile o devo solo ciclo attraverso la raccolta e generare le opzioni manualmente?
umm .. questo crea 2 opzioni extra, entrambe con nome uguale a valore, "O creane una nuova" e "nuova" – andi
I anche provato con un hash invece di un array, Hash ["nome", "creane uno nuovo", "id", "nuovo"], ma ottengo un "impossibile convertire Hash in array" .. figure .. – andi
quindi .. questo dovrebbe essere, ma, qualche idea su come impostare un valore diverso dal testo all'interno dell'opzione? – andi