【发布时间】:2014-09-10 16:28:18
【问题描述】:
在一个控制器函数中,我提取了所有attributes 和我已经使用的属性。
所有属性:
$attributeNames = array('' => 'Select Attribute Name') + AttributeName::lists('name' , 'id');
已经采用的属性:
$selectedAttributeNames = $xmlDocument->masterInformation->masterAttributes;
请问如何将selectedAttributeNames 设为disable?
这是var_dump($selectedAttributeNames)的输出:
object(Illuminate\ Database\ Eloquent\ Collection) #312 (1) {
["items":protected]= > array(1) {
[0] => object(MasterAttribute) #310 (20) {
["table":protected]= > string(16) "master_attribute"
["guarded": protected] => array(1) {
[0] => string(2) "id"
}
["connection": protected] => NULL["primaryKey": protected] => string(2) "id"
["perPage": protected] => int(15)["incrementing"] => bool(true)["timestamps"] => bool(true)["attributes": protected] => array(7) {
["id"] => int(1)["xpath"] => string(17)
"this is the xpath"
["attribute_name_id"] => int(1)["master_information_id"] => int(6)["default_value"] => string(25) "This is the default value"
["created_at"] => string(19) "2014-07-19 17:53:55"
["updated_at"] => string(19) "2014-07-19 17:53:55"
}
["original": protected] => array(7) {
["id"] => int(1)["xpath"] => string(17) "this is the xpath"
["attribute_name_id"] => int(1)["master_information_id"] => int(6)["default_value"] => string(25) "This is the default value"
["created_at"] => string(19) "2014-07-19 17:53:55"
["updated_at"] => string(19) "2014-07-19 17:53:55"
}
["relations": protected] => array(0) {}
["hidden": protected] => array(0) {}
["visible": protected] => array(0) {}
["appends": protected] => array(0) {}
["fillable": protected] => array(0) {}
["dates": protected] => array(0) {}
["touches": protected] => array(0) {}
["observables": protected] => array(0) {}
["with": protected] => array(0) {}
["morphClass": protected] => NULL["exists"] => bool(true)
}
}
}
【问题讨论】:
-
this question 是否与您所追求的相似?
-
@halfer 也许我不知道。这个问题是使用刀片代码,但在我的情况下,我不知道如何使用它,因为选定属性的列表在控制器中。我可以将它发送到视图,但你能帮我构建
select标签吗? -
没看清楚P
-
@WereWolf-TheAlpha 好的,让我解释一下。我有一个想法来创造一些东西。该视图有一个形式。表单有一个带有选项的选择。当用户想再次使用该表单时,选择元素应禁用已选择的选项。请问你现在找到我了吗?
-
您能否通过 var_dump($selectedAttributeNames) 显示
$selectedAttributeNames中的内容?
标签: php laravel laravel-4 blade