form

转:drupal修改用户登录模块

六月ゝ 毕业季﹏ 提交于 2020-02-22 07:01:15
Drupal7自定义用户登录 转载:Drupal7的User Login用户登录教程 http://blog.163.com/ziyun_2006/blog/static/681973652012102792140192/ 网站的登录和注册,大家肯定不会陌生了,而对于玩 drupal 的朋友来说,更不会陌生吧。接触 drupal 不久,也并不怎么会使用其核心的东西,就比如说我要在页面头部加一个“登录 | 退出”这样的链接,就会让我够受的了,如果要像下面图示的User Login框 头就更大了。所以这次花了大力气专门去了解和学习这一块的东西,终于还是让我实现了,为了像我这样的初学者不在头痛,贴出来分享,希望能给需要帮助的朋友带来一丝灵感。那我们开始吧: 第一种方法:在page.tpl.php添加User Login & y7 W! A4 y: G! ` 这种方法就是在你的主题下的page.tpl.php文件中加上一些User Login的代码,这些代码还是算比较简单的,只要稍有一点PHP基础的朋友都是没有问题,像咱这种没有PHP概念的,还是需要花点时间学习一下。好了我们先来看需要增加的代码吧 page.tpl.php: 5 `3 d! X6 q i$ W/ V <?php if($user->uid): ?> <aside class="login-bar c4"> <span

Drupal7 自定义表单元素(form element)

时间秒杀一切 提交于 2020-02-22 07:00:58
<? php /* * * Implements hook_element_info(). */ function example_element_info() { $types = array ( ' example ' => array ( ' #input ' => TRUE , ' #tree ' => TRUE , ' #process ' => array ( ' example_process ' ) , ' #theme ' => array ( ' example ' ) , ' #pre_render ' => array ( ' form_pre_render_conditional_form_element ' ) , ' #value_callback ' => ' example_value_callback ' ) ); return $types ; } /* * * element显示前对element内参数的处理 */ function example_process( $element , $form_state ) { if ( isset ( $element [ ' default_value ' ])) { $element [ ' #default_value ' ] = $element [ ' default_value ' ];

drupal Form

时间秒杀一切 提交于 2020-02-22 07:00:11
1, 首先在 hook_menu 中定义path, 例如下面定义的path为user/register。 $items['user/register'] = array( 'title' => 'Create new account', 'page callback' => 'drupal_get_form', //一般都是使用'drupal_get_form'函数 'page arguments' => array('register_user_form'), //'register_user_form'是指构造$form数组的函数,同时该字符串还会作为form id。 'access callback' => 'user_register_access', ); 2,定义'register_user_form'函数 function register_user_form() { $period = drupal_map_assoc(array(3600,10800,21600,32400,43200,86400),'format_interval'); $form['email'] = array('#type' => 'textfield','#size' => '45', '#default_value'=>'jerry jia cecy'); $form[

FORM组件

天涯浪子 提交于 2020-02-22 05:19:52
form组件 忽略的 一个问题: 没有对用户输入的值进行校验 1:前台和后台都要校验 2:减少后台数据库的压力 views.py: from django.forms import Form from django.forms import fields class LoginForm(Form): #验证的规则 username=fields.CharField( required=True, max_length=18, min_length=6, error_message={ "required":'不能为空', "max_length":'太长了', "min_length":"太短了", }) pwd =fields.CharField() def login(request): if request.method=='GEt': return render(request,'login.html') else: obj =LoginForm(request.POST) print(obj) if obj.is_valid(): print(obj.cleaned_data)##对象 else: print(obj.errors)## 对象__str__ return render(request,'login.html',{'obj':obj}) html:

点表优化程序(基于多继承和基于单继承的对比)

浪子不回头ぞ 提交于 2020-02-21 11:44:41
界面代码 # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'try_gui.ui' # # Created by: PyQt5 UI code generator 5.13.1 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore , QtGui , QtWidgets class Ui_Form ( object ) : def setupUi ( self , Form ) : Form . setObjectName ( "Form" ) Form . resize ( 493 , 473 ) self . xianshi2 = QtWidgets . QTextEdit ( Form ) self . xianshi2 . setGeometry ( QtCore . QRect ( 30 , 100 , 251 , 361 ) ) self . xianshi2 . setLineWrapMode ( QtWidgets . QTextEdit . WidgetWidth ) self . xianshi2 . setReadOnly ( True )

django之CreateView

我的梦境 提交于 2020-02-21 07:19:07
模型 from .BaseModel import BaseModel from django.db import models from django.urls import reverse class AdvPosition(BaseModel): name = models.CharField(max_length=255, help_text = "广告位名称") def get_absolute_url(self): return reverse('backend:adv-position-index') class Meta(BaseModel.Meta): db_table = 'adv_position' 模型中需要设定跳转地址,在保存成功后会根据这个地址跳转。 url path('adv-position/create', AdvPositionCreateView.as_view(), name = 'adv-position-create'), 由于model使用了app_name 所以需要再urls.py中添加 app_name = 'backend' create.html <form class="form-horizontal" action="{{ request.get_full_path }}" method="post"> {% csrf

关于后台接口参数是以@RequestBody修饰,页面如何传参问题

六眼飞鱼酱① 提交于 2020-02-21 05:14:20
版本1: 只需把ajax请求的headers的"Content-Type"设置为"application/json"即可 版本2: @requestBody注解常用来处理content-type不是默认的application/x-www-form-urlcoded编码的内容,比如说:application/json或者是application/xml等。一般情况下来说常用其来处理application/json类型。并且@requestbody传送的参数需要是son对象即可; 附:form默认的提交方式content-type是x-www-form-urlencoded,会将传递的参数转换成key-value方式。 来源: CSDN 作者: qq1225095213 链接: https://blog.csdn.net/qq_37769323/article/details/104416051

vue+router.beforeEach实现登录验证路由拦截

烂漫一生 提交于 2020-02-21 01:12:14
1.在配置路由路径的文件夹里加上如下图的语句 2.在main.js里添加 3.login.vue <template> <div> <!-- 表单--> <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm"> <!-- 用户名一行--> <el-row class="rowStyle"> <el-col :span="18" :offset="3"> <el-form-item prop="userName"> <el-input class="inputStyle" v-model="ruleForm.userName" placeholder="用户名"></el-input> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="18" :offset="3"> <el-form-item prop="password"> <el-input class="inputStyle" v-model="ruleForm.password" placeholder="密码"></el-input> </el-form-item> </el-col> </el-row> <el-row class="rowStyle

IDEA 接口调试插件 HTTP Client

会有一股神秘感。 提交于 2020-02-20 11:40:36
界面客户端 使用手册 https://www.jetbrains.com/help/idea/testing-restful-web-services.html 打开方式 Tools -> HTTP Client -> Test RESTful Web Service 文本客户端 使用手册 https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html 特点 纯文本编写 支持统一配置 支持 scripts 脚本 创建新的请求文件 Scratch files (全局文件) physical files(项目文件) live templates 支持 HTTP 1.1 所有方法 POST、GET、PUT、DELETE、HEAD、OPTIONS、TRACE、CONNECT GET ### Get request with a header GET https://httpbin.org/ip Accept: application/json ### Get request with parameter GET https://httpbin.org/get?show_env=1 Accept: application/json ### Get request with environment

Django - ModelForm

 ̄綄美尐妖づ 提交于 2020-02-20 07:54:42
一、原生form https://www.cnblogs.com/yuanchenqi/articles/7614921.html 案例: 步骤: 1.models.py ... makemigrations migrate from django.db import models # Create your models here. class Book(models.Model): title = models.CharField(max_length=32) price = models.DecimalField(max_digits=8,decimal_places=2) # 999999.99 date = models.DateField() publish = models.ForeignKey("Publish",on_delete=models.CASCADE) authors = models.ManyToManyField("Author") def __str__(self): return self.title class Publish(models.Model): name = models.CharField(max_length=32) def __str__(self): return self.name class Author(models