name = updateform
description = form will show add edit delte functionality
core = 6.x
version = "6.x-1.9"
<?php
function updateform_install()
{
drupal_install_schema('updateform');
}
function updateform_uninstall()
{
drupal_uninstall_schema('updateform');
}
<?php
function updateform_help($path, $arg)
{
if ($path == 'admin/help#updateform')
{
$txt = 'This module provides a way for an administrator to send'.
'email to a user. '.
'It assumes that the Drupal mailer is configured.';
return '
'. t($txt) .'
';
}
}
function updateform_menu()
{
$items['admin/updateform/data_entry_form'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'drupal_get_form',
'page arguments'=>array('updateform_data_entry_form'));
$items['admin/updateform/delete/email'] = array(
'title' => t('Delete email'),
'page callback' => 'drupal_get_form',
'page arguments' => array('updateform_delete_confirm',2),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK, );
$items['admin/updateform/display_email'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'display_updateform_page');
return $items;
}
function updateform_delete_confirm(&$form_state, $formid)
{
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,);
return confirm_form($form,t('Are you sure you want to delete this email?'),
isset($_GET['destination']) ? $_GET['destination'] : "email",t('This action cannot be undone.'),t('Delete'),t('Cancel'));
}
function updateform_delete_confirm_submit($form, &$form_state)
{
$form_values = $form_state['values'];
if ($form_state['values']['confirm'])
{
$email = $form_state['values']['_email'];
$id=$_GET['id'];
$query = "DELETE FROM {emailform} where id=$id";
$rs = db_query($query);
drupal_set_message(t('email- has been deleted successfully.'));
}
}
function updateform_data_entry_form() {
$form = array();
$form['#redirect'] = 'admin/updateform/display_email';
$form['email']=array(
'#type'=>'textfield',
'#default_value'=>' ',
'#title'=>t('Enter a email'),
'#size'=>60,
'#maxlength'=>128,
'#weight'=>1);
$form['submit']=array(
'#type'=>'submit',
'#value'=>'Add email',
'#weight'=>2);
return $form;
}
function updateform_data_entry_form_submit($node, &$form_state) {
$sql = "insert into {emailform} (email) values ('%s')";
$result1 = db_query($sql, $form_state['values']['email']);
if ($result1)
{
$message="email has been sent to successfully";
drupal_set_message(t($message));
} else {
$message1="some error occour plz try again";
drupal_set_message(t($message1));
}
}
function display_updateform_page()
{
$result1 = db_query( "select * from {emailform}");
$rows['data'] = array();
while ($data = db_fetch_object($result1))
{
$items.= $data->email. l('delete','admin/updateform/delete/email', array('query' => 'id=5'))."
";
}
$linktoback = l('Add More Email','admin/updateform/data_entry_form');
return $items."
"."========================="."
".$linktoback;
}
function updateform_perm()
{
return array('access updateform');
}
Comments
Comment #1
joachim commentedI'm sorry I don't understand the question or the problem. Module builder provides you with scaffold code for module hooks, it won't do all your coding for you!
Comment #2
brajendrashukla commentedi have created a custom updateform module.and create a database table for this name emailform with 2 fields id and email.i have done the submit and delete functionality but i am unable to perform edit functionality in my custom module form.
plz reply any one , waiting for positive response...............................
Comment #3
brajendrashukla commentedfinally i have done it but manually not base on id here is my code
here is my .module file
<?php
function updateform_help($path, $arg)
{
if ($path == 'admin/help#updateform')
{
$txt = 'This module provides a way for an administrator to send'.
'email to a user. '.
'It assumes that the Drupal mailer is configured.';
return '
'. t($txt) .'
';
}
}
function updateform_menu()
{
$items['admin/updateform/data_entry_form'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'drupal_get_form',
'page arguments'=>array('updateform_data_entry_form'));
$items['admin/updateform/delete/email'] = array(
'title' => t('Delete email'),
'page callback' => 'drupal_get_form',
'page arguments' => array('updateform_delete_confirm',3),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK,);
$items['admin/updateform/display_email'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'display_updateform_page');
$items['admin/updateform/edit_email'] = array(
'title' => t('Edit Form'),
'page callback' => 'drupal_get_form',
'page arguments' => array('updateform_edit_confirm', 2),
'access arguments' => array('administer users'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function updateform_edit_confirm(&$form_state,$formid)
{
$form = array();
$form['#redirect'] = 'admin/updateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,
);
$form['email']=array(
'#title'=>t('Email'),
'#type'=>'textfield',
);
return confirm_form($form,t(''),
isset($_GET['destination']) ? $_GET['destination'] : "email",
t(''),t('Edit'),t('Cancel'));
}
function updateform_edit_confirm_submit($form, &$form_state)
{
if ($form_state['values']['confirm'])
{
$id = $form_state['values']['id'];
$email = $form_state['values']['email'];
$query = "UPDATE {emailform} SET email = '$email' WHERE id=12";
$rs = db_query($query);
if($rs)
{
drupal_set_message(t('email- has been updated successfully.'));
}
else
drupal_set_message(t('OOPS1 SOME PROBLEM OCCURE IN EMAIL UPDATION.'));
}
}
function updateform_delete_confirm(&$form_state, $formid)
{
$form['#redirect'] = 'admin/updateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,);
return confirm_form($form,t('Are you sure you want to delete this email?'),
isset($_GET['destination']) ? $_GET['destination'] : "email",t('This action cannot be undone.'),t('Delete'),t('Cancel'));
}
function updateform_delete_confirm_submit($form, &$form_state)
{
//$form_values = $form_state['values'];
if ($form_state['values']['confirm'])
{
$email = $form_state['values']['_email'];
$id=$_GET['id'];
$query = "DELETE FROM {emailform} where id=$id";
$rs = db_query($query);
drupal_set_message(t('email- has been deleted successfully.'));
}
}
function updateform_data_entry_form()
{
$form = array();
$form['#redirect'] = 'admin/updateform/display_email';
$form['email']=array(
'#type'=>'textfield',
'#default_value'=>' ',
'#title'=>t('Enter a email'),
'#size'=>60,
'#maxlength'=>128,
'#weight'=>1);
$form['submit']=array(
'#type'=>'submit',
'#value'=>'Add email',
'#weight'=>2);
return $form;
}
function updateform_data_entry_form_submit($node, &$form_state)
{
$sql = "insert into {emailform} (email) values ('%s')";
$result1 = db_query($sql, $form_state['values']['email']);
if ($result1)
{
$message="email has been sent to successfully";
drupal_set_message(t($message));
}
else
{
$message1="some error occour plz try again";
drupal_set_message(t($message1));
}
}
function display_updateform_page()
{
$result1 = db_query( "select * from {emailform}");
$rows['data'] = array();
while ($data = db_fetch_object($result1))
{
$items.= $data->email." ". l('delete','admin/updateform/delete/email', array('query' => 'id=12'))." ". l('edit','admin/updateform/edit_email', array('query' => 'id =12'))."
";
}
$linktoback = l('Add More Email','admin/updateform/data_entry_form');
return $items."
"."========================="."
".$linktoback;
}
function updateform_perm()
{
return array('access updateform');
}
Comment #4
brajendrashukla commentedhttp://drupal.org/node/565324 read this for help
Comment #5
brajendrashukla commentednewupdateform.module to display the page as well as block
<?php
function newupdateform_help($path, $arg)
{
if ($path == 'admin/help#newupdateform')
{
$txt = 'This module provides a way for an administrator to send'.
'email to a user. '.
'It assumes that the Drupal mailer is configured.';
return '
'. t($txt) .'
';
}
}
function newupdateform_menu()
{
$items['newupdateform/data_entry_form'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('access content'),
'page callback' => 'drupal_get_form',
'page arguments'=>array('newupdateform_data_entry_form'));
$items['admin/newupdateform/delete/email'] = array(
'title' => t('Delete email'),
'page callback' => 'drupal_get_form',
'page arguments' => array('newupdateform_delete_confirm',3),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK,);
$items['admin/newupdateform/display_email'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'display_newupdateform_page');
$items['admin/newupdateform/edit_email'] = array(
'title' => t('Edit Form'),
'page callback' => 'drupal_get_form',
'page arguments' => array('newupdateform_edit_confirm', 2),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK,
);
return $items;
}
function newupdateform_edit_confirm(&$form_state,$formid)
{
$form = array();
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,
);
$form['email']=array(
'#title'=>t('Email'),
'#type'=>'textfield',
);
return confirm_form($form,t(''),
isset($_GET['destination']) ? $_GET['destination'] : "email",
t(''),t('Edit'),t('Cancel'));
}
function newupdateform_edit_confirm_submit($form, &$form_state)
{
if ($form_state['values']['confirm'])
{
//$id = $form_state['values']['id'];
//$id=$_GET['id'];
//var_dump($id);
$email = $form_state['values']['email'];
$query = "UPDATE {emailform} SET email = '$email' WHERE id=15";
$rs = db_query($query);
if($rs)
{
drupal_set_message(t('email- has been updated successfully.'));
}
else
drupal_set_message(t('OOPS1 SOME PROBLEM OCCURE IN EMAIL UPDATION.'));
}
}
function newupdateform_delete_confirm(&$form_state, $formid)
{
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,);
return confirm_form($form,t('Are you sure you want to delete this email?'),
isset($_GET['destination']) ? $_GET['destination'] : "email",t('This action cannot be undone.'),t('Delete'),t('Cancel'));
}
function newupdateform_delete_confirm_submit($form, &$form_state)
{
//$form_values = $form_state['values'];
if ($form_state['values']['confirm'])
{
$email = $form_state['values']['_email'];
$id=$_GET['id'];
$query = "DELETE FROM {emailform} where id=$id";
$rs = db_query($query);
drupal_set_message(t('email- has been deleted successfully.'));
}
}
function newupdateform_block($op='list',$delta=0,$edit=array()) {
$block = array();
if($op == 'list') {
$block['0'] = array(
'info' => t('newupdateform block'),
);
return $block;
} else if($op == 'view') {
switch ($delta) {
case 0:
$block['subject'] = t('newupdateform block subject');
$block['content'] = drupal_get_form('newupdateform_data_entry_form');
return $block;
break;
}
}
}
function newupdateform_data_entry_form()
{
$form = array();
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['email']=array(
'#type'=>'textfield',
'#default_value'=>' ',
'#title'=>t('Enter a email'),
'#size'=>60,
'#maxlength'=>90,
'#weight'=>1);
$form['submit']=array(
'#type'=>'submit',
'#value'=>'Add email',
'#weight'=>2);
return $form;
}
function newupdateform_data_entry_form_submit($node, &$form_state)
{
$sql = "insert into {emailform} (email) values ('%s')";
$result1 = db_query($sql, $form_state['values']['email']);
if ($result1)
{
$message="email has been sent to successfully";
drupal_set_message(t($message));
}
else
{
$message1="some error occour plz try again";
drupal_set_message(t($message1));
}
}
function display_newupdateform_page()
{
$result1 = db_query( "select * from {emailform}");
$rows['data'] = array();
while ($data = db_fetch_object($result1))
{
$items.= $data->email." ". l('delete','admin/newupdateform/delete/email', array('query' => 'id=15'))." ". l('edit','admin/newupdateform/edit_email', array('query' => 'id =15'))."
";
}
$linktoback = l('Add More Email','');
return $items."
"."========================="."
".$linktoback;
}
function newupdateform_perm()
{
return array('access newupdateform');
}
Comment #6
joachim commentedI'm sorry, but I don't understand what you're trying to say with all this.
Comment #7
brajendrashukla commented<?php
function newupdateform_help($path, $arg)
{
if ($path == 'admin/help#newupdateform')
{
$txt = 'This module provides a way for an administrator to send'.
'email to a user. '.
'It assumes that the Drupal mailer is configured.';
return '
'. t($txt) .'
';
}
}
function newupdateform_menu()
{
$items['newupdateform/data_entry_form'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('access content'),
'page callback' => 'drupal_get_form',
'page arguments'=>array('newupdateform_data_entry_form'));
$items['admin/newupdateform/delete/email'] = array(
'title' => t('Delete email'),
'page callback' => 'drupal_get_form',
'page arguments' => array('newupdateform_delete_confirm',3),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK,);
$items['admin/newupdateform/display_email'] = array(
'type' => MENU_CALLBACK,
'access arguments' => array('administer users'),
'page callback' => 'display_newupdateform_page');
$items['admin/newupdateform/edit_email'] = array(
'title' => t('Edit Form'),
'page callback' => 'drupal_get_form',
'page arguments' => array('newupdateform_edit_confirm', 2),
'access arguments' => array('administer users'),
'type' => MENU_CALLBACK,
);
return $items;
}
function newupdateform_edit_confirm(&$form_state,$formid)
{
$form = array();
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,
);
$form['email']=array(
'#title'=>t('Email'),
'#type'=>'textfield',
);
return confirm_form($form,t(''),
isset($_GET['destination']) ? $_GET['destination'] : "email",
t(''),t('Edit'),t('Cancel'));
}
function newupdateform_edit_confirm_submit($form, &$form_state)
{
if ($form_state['values']['confirm'])
{
$id = $form_state['values']['id'];
$id=$_GET['id'];
//$id=$_GET['id'];
//var_dump($id);
echo "hhhhhhhhhhhhhhhhh";
$email = $form_state['values']['email'];
$query = "UPDATE {emailform} SET email = '$email' WHERE id='$id'";
$rs = db_query($query);
if($rs)
{
drupal_set_message(t('email- has been updated successfully.'));
}
else
drupal_set_message(t('OOPS1 SOME PROBLEM OCCURE IN EMAIL UPDATION.'));
}
}
function newupdateform_delete_confirm(&$form_state, $formid)
{
$form=array();
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['_email'] = array(
'#type' => 'value',
'#value' => $email,);
return confirm_form($form,t('Are you sure you want to delete this email?'),
isset($_GET['destination']) ? $_GET['destination'] : "email",t('This action cannot be undone.'),t('Delete'),t('Cancel'));
}
function newupdateform_delete_confirm_submit($form, &$form_state)
{
$form_values = $form_state['values'];
if ($form_state['values']['confirm'])
{
echo "hi";
$email = $form_state['values']['_email'];
$id= $form_state['values']['id'];
$id=$_GET['id'];
$query = "DELETE FROM {emailform} where id='$id'";
$rs = db_query($query);
drupal_set_message(t('email- has been deleted successfully.'));
}
}
function newupdateform_block($op='list',$delta=0,$edit=array()) {
$block = array();
if($op == 'list') {
$block['0'] = array(
'info' => t('newupdateform block'),
);
return $block;
} else if($op == 'view') {
switch ($delta) {
case 0:
$block['subject'] = t('newupdateform block subject');
$block['content'] = drupal_get_form('newupdateform_data_entry_form');
return $block;
break;
}
}
}
function newupdateform_data_entry_form()
{
$form = array();
$form['#redirect'] = 'admin/newupdateform/display_email';
$form['email']=array(
'#type'=>'textfield',
'#default_value'=>' ',
'#title'=>t('Enter a email'),
'#size'=>60,
'#maxlength'=>90,
'#weight'=>1);
$form['submit']=array(
'#type'=>'submit',
'#value'=>'Add email',
'#weight'=>2);
return $form;
}
function newupdateform_data_entry_form_submit($node, &$form_state)
{
$sql = "insert into {emailform} (email) values ('%s')";
$result1 = db_query($sql, $form_state['values']['email']);
if ($result1)
{
$message="email has been sent to successfully";
drupal_set_message(t($message));
}
else
{
$message1="some error occour plz try again";
drupal_set_message(t($message1));
}
}
function display_newupdateform_page()
{
$result1 = db_query( "select * from {emailform}");
$rows['data'] = array();
while ($data = db_fetch_object($result1))
{
echo $data->id;
$items.= $data->email." ". l('delete','admin/newupdateform/delete/email', array('query' =>array('id'=>$data->id)))." ". l('edit','admin/newupdateform/edit_email', array('query' =>array('id'=>$data->id)))."
.
.";
}
$linktoback = l('Add More Email','newupdateform/data_entry_form');
return $items."
"."========================="."
".$linktoback;
}
function newupdateform_perm()
{
return array('access newupdateform');
}
Comment #8
joachim commentedCould you please stop posting all this code in this project's issue queue? I don't see what you're trying to accomplish by doing this!