示例#1
0
function dl_for(moojon_base_model $model, $column_names = array(), $attributes = array())
{
    if (!$column_names) {
        $column_names = $model->get_ui_column_names(array($model->get_to_string_column()));
    }
    $attributes = try_set_attribute($attributes, 'id', 'show_' . get_class($model) . '_dl');
    $dt_dd_tags = array();
    foreach ($column_names as $column_name) {
        $column = $model->get_column($column_name);
        if ($relationship = find_has_one_relationship($model, $column_name)) {
            $name = $relationship->get_name();
            $content = member_tag($model->{$name});
        } else {
            if ($relationship = find_belongs_to_relationship($model, $column_name)) {
                $name = $relationship->get_name();
                $content = member_tag($model->{$name});
            } else {
                $content = $column->get_value();
            }
        }
        $dt_dd_tags[] = dt_tag(title_text($column_name) . ':');
        $dt_dd_tags[] = dd_tag(format_content($model, $column, $content));
    }
    return dl_tag($dt_dd_tags, $attributes);
}
示例#2
0
function error_dl($message, $errors = array(), $attributes = array())
{
    $children = array();
    $attributes = try_set_attribute($attributes, 'class', 'errors');
    if (count($errors)) {
        $children[] = dt_tag($message);
        foreach ($errors as $key => $value) {
            $children[] = dd_tag(label_tag($value, $key));
        }
        $return = dl_tag($children, $attributes);
    } else {
        $return = div_tag($children, $attributes);
    }
    return $return;
}