Gallery3 yazılım Kohana formda onay kutusunu

0 Cevap php

Ben Kohana çerçeve dayanmaktadır gallery3 php yazılımı kullanıyorum. Herkes albüm bilgi formu için bir onay kutusu eklemek nasıl biliyor mu?

Ben bu gibi çalıştı:

static function get_edit_form($parent) { $form = new Forge( "albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form")); $form->hidden("from_id")->value($parent->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);
}

VE

public function update($album_id) { access::verify_csrf(); $album = ORM::factory("item", $album_id); access::required("view", $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));
}

}

Alan formda göstermek, ama alan değeri DB kaydedilen almaz. DB bir tinyint (1).

0 Cevap