Я использую программное обеспечение gallery3 php, основанное на фреймворке Kohana Кто-нибудь знает, как добавить флажок в форму информации об альбоме?
Я пытался так:
статическая функция get_edit_form ($ parent) {
$ form = new Forge (
"album / update / {$ parent-> id}", "", "post", array ("id" => "g-edit-album-form"));
$ Форма-> скрытый ( "from_id") -> значение ($ родительский,> идентификатор);
$ group = $ form-> group ("edit_item") -> label (t ("Edit Album"));
$group->input("title")->label(t("Title"))->value($parent->title)
->error_messages("required", t("You must provide a title"))
->error_messages("length", t("Your title is too long"));
$group->textarea("description")->label(t("Description"))->value($parent->description);
/* MPK: information fields for albums */
$group->textarea("information")->label(t("Information text"))->value($parent->information);
$group->checkbox("info")->label(t("Informational"))->value($parent->info);
if ($parent->id != 1) {
$group->input("name")->label(t("Directory Name"))->value($parent->name)
->error_messages("conflict", t("There is already a movie, photo or album with this name"))
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
->error_messages("no_trailing_period", t("The directory name can't end in \".\""))
->error_messages("required", t("You must provide a directory name"))
->error_messages("length", t("Your directory name is too long"));
$group->input("slug")->label(t("Internet Address"))->value($parent->slug)
->error_messages(
"conflict", t("There is already a movie, photo or album with this internet address"))
->error_messages(
"not_url_safe",
t("The internet address should contain only letters, numbers, hyphens and underscores"))
->error_messages("required", t("You must provide an internet address"))
->error_messages("length", t("Your internet address is too long"));
} else {
$group->hidden("name")->value($parent->name);
$group->hidden("slug")->value($parent->slug);
}
И
обновление публичной функции ($ album_id) {
доступа :: verify_csrf ();
$ album = ORM :: factory ("item", $ album_id);
access :: required ("просмотр", $ album);
access :: required ("edit", $ album);
$form = album::get_edit_form($album);
try {
$valid = $form->validate();
$album->title = $form->edit_item->title->value;
$album->description = $form->edit_item->description->value;
/* MPK: information fields for albums */
$album->information = $form->edit_item->information->value;
$album->info = $form->edit_item->info->value;
$album->sort_column = $form->edit_item->sort_order->column->value;
$album->sort_order = $form->edit_item->sort_order->direction->value;
if (array_key_exists("name", $form->edit_item->inputs)) {
$album->name = $form->edit_item->inputs["name"]->value;
}
$album->slug = $form->edit_item->slug->value;
$album->validate();
} catch (ORM_Validation_Exception $e) {
// Translate ORM validation errors into form error messages
foreach ($e->validation->errors() as $key => $error) {
$form->edit_item->inputs[$key]->add_error($error, 1);
}
$valid = false;
}
if ($valid) {
$album->save();
module::event("item_edit_form_completed", $album, $form);
log::success("content", "Updated album", "<a href=\"albums/$album->id\">view</a>");
message::success(t("Saved album %album_title",
array("album_title" => html::purify($album->title))));
if ($form->from_id->value == $album->id) {
// Use the new url; it might have changed.
json::reply(array("result" => "success", "location" => $album->url()));
} else {
// Stay on the same page
json::reply(array("result" => "success"));
}
} else {
json::reply(array("result" => "error", "html" => (string)$form));
}
*
} * 1013
Поле отображается в форме, но значение поля не сохраняется в БД. В БД это tinyint (1).