drne47241 2015-03-26 20:13
浏览 56
已采纳

如何在Elgg中保存对象

I'm trying to save an object in elgg, but nothing happens. On button click the page starts reloading as if to save the object, but nothing happens at all. The page only reloads. Nothing gets persisted.

Any help will be greatly appreciated.

Rev/start.php

$lib = elgg_get_plugins_path() . 'Rev/lib';
elgg_register_library('Rev', "$lib/Rev.php");
elgg_load_library('Rev');

$base = elgg_get_plugins_path() . 'Rev/actions';
elgg_register_action("Rev/room_reservation", "$base/room_reservation.php");

Rev/actions/room_reservation.php

<?php
/**
* Save
*/
// get the form values
$category = get_input('category');
$full_names = get_input('full_names');
$check_in_date = get_input('check_in_date');
$check_out_date = get_input('check_out_date');

$result = help_save_topic($category, $full_names, $check_in_date, $check_out_date);
if (!$result) {
    register_error(elgg_echo('Error Saving'));
} else {
    system_message(elgg_echo('Successfully Saved'));
    $user = elgg_get_logged_in_user_entity();
    forward($user->getURL());
}

Rev/lib/Rev.php

function reservation_save($category, $full_names, $check_in_date, $check_out_date) {
    $reservation = new ElggObject();
    $reservation->subtype = 'reservation';
    $reservation->category = $category;
    $reservation->full_names = $full_names;
    $reservation->check_in_date = $check_in_date;
    $reservation->check_out_date = $check_out_date;
    $reservation->save();
    if (!$guid) {
        return false;
    }
    return true;
}

Rev/views/default/forms/olive_green/room_reservation.php

<div class="olive_color" >The Occupant's Full Names</div>
<div>
    <?php echo elgg_view('input/text', array(
        'name' => 'full_names',
        'class' => 'login_input',
        ));
        ?>
    </div>
    <div class="room_category">
        <?php
        $categories = rooms_get_categories();
        echo elgg_view('input/dropdown', array(
            'name' => 'category',
            'options_values' => $categories,
            ));
            ?>
        </div>
        <div class="check_in_out">
            <input name="check_in_date" class="check_in_out_input" type="text" placeholder="Enter check in date ..." />
            <input name="check_out_date" class="check_in_out_input" type="text" placeholder="Enter check out date ..." />
        </div>
        <div> <?php echo elgg_view('input/submit', array('value' => 'Check availability', 'id' => 'login_submit')); ?> </div>
  • 写回答

1条回答 默认 最新

  • douzao2590 2015-04-24 12:58
    关注

    help_save_topic($category, $full_names, $check_in_date, $check_out_date);

    you have declared your function name as wrong

    reservation_save($category, $full_names, $check_in_date, $check_out_date)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测