DrupalBin
Submit Code
About
Recent Posts
Code
Code
PHP for default argument
imagefield in other form
autocomplete
Code
Fix for 123
123
user has nodes of type
Code
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
simpletest
test
theme
user
views
more tags
Home
Fix for formulario
View
Fix
July 26, 2008 - 1:00pm — Anonymous
<code>
<?php
/**
* Formulario que permite guardar las partidas jugadas
* Form to save the game.
*/
function
alta_partida_form
(
$node
)
{
$form
[
'alta_partida'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'alta de partidas'
)
)
;
// Nombre del jugador a
$form
[
'jugador_a'
]
=
array
(
'#type'
=
>
'value'
,
'#value'
=
>
$user
-
>
uid
,
)
;
// Nombre del ejercito del jugador a
$form
[
'jugador_a_ejercito'
]
=
array
(
'#type'
=
>
'value'
,
'#value'
=
>
$user
-
>
profile_ejercito
,
)
;
// fieldset para agrupar los datos del jugador b
$form
[
'contrincante'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'Datos de tu contrincante'
)
,
'#weight'
=
>
5
,
'#collapsible'
=
>
TRUE
,
'#collapsed'
=
>
FALSE
,
)
;
// Ejercito del jugador b
$form
[
'contrincante'
]
[
'jugador_b_ejercito'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'selecciona el ejercito de tu contrincante:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'Marines'
)
,
'1'
=
>
t
(
'Orkos'
)
,
'2'
=
>
t
(
'Eldars'
)
,
)
,
'default_value'
=
>
t
(
'seleccina un ejercito'
)
,
'#weight'
=
>
-15,
)
;
// Nombre del jugador b
$form
[
'contrincante'
]
[
'jugador_b_'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'¿Como se llamaba tu contrincante?:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'General Lee'
)
,
'1'
=
>
t
(
'Mc Arthur'
)
,
'2'
=
>
t
(
'Almirante Nelson'
)
,
'3'
=
>
t
(
'Godoy'
)
,
)
,
'#weight'
=
>
-14,
)
;
//fieldset de la campaña
$form
[
'campanya'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'Datos de la campaña'
)
,
'#weight'
=
>
4
,
'#collapsible'
=
>
TRUE
,
'#collapsed'
=
>
FALSE
,
)
;
//nombre de la campanya.
$form
[
'campanya'
]
[
'nombre_campanya'
]
=
array
(
'#type'
=
>
'item'
,
'#title'
=
>
t
(
'Nombre de la campaña:'
)
,
'#value'
=
>
$user
-
>
profile_campanya
,
'#weight'
=
>
-4,
)
;
//lugar de la partida
$form
[
'campanya'
]
[
'lugar'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'Donde se ha jugado la partida:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'Paris centro'
)
,
'1'
=
>
t
(
'Sudeste de paris'
)
,
'2'
=
>
t
(
'En los suburbios'
)
,
'3'
=
>
t
(
'En el almacen del puerto'
)
,
)
,
'#weight'
=
>
-3,
)
;
//fieldset del tipo de partida
$form
[
'tipo_partida'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'Tipo de partida que se ha jugado'
)
,
'#weight'
=
>
2
,
'#collapsible'
=
>
TRUE
,
'#collapsed'
=
>
FALSE
,
)
;
//tipo de batalla, hace referencia a la cantidad de puntos que se juegan en la partida.
$form
[
'tipo_paritda'
]
[
'tipo_batalla'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'Donde se ha jugado la partida:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'escaramuzas'
)
,
'1'
=
>
t
(
'patrullas'
)
,
'2'
=
>
t
(
'normal'
)
,
'3'
=
>
t
(
'grande'
)
,
'4'
=
>
t
(
'enorme'
)
,
)
,
'#weight'
=
>
-5,
)
;
//tipo de batalla, hace referencia al tipo de miniaturas, tamaño, que se utiliza en la partida..
$form
[
'tipo_paritda'
]
[
'tipo_ejercito'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'Donde se ha jugado la partida:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'06mm a 15mm'
)
,
'1'
=
>
t
(
'16 mm a 25mm'
)
,
'2'
=
>
t
(
'26 mm a 35mm'
)
,
'3'
=
>
t
(
'36mm a 55mm'
)
,
'4'
=
>
t
(
'barcos'
)
,
'5'
=
>
t
(
'aviones'
)
,
'6'
=
>
t
(
'naves espaciales'
)
,
)
,
'#weight'
=
>
-4,
)
;
//fieldset del tipo de misión que se ha jugado en la partida
$form
[
'tipo_mision'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'Tipo de misión'
)
,
'#weight'
=
>
1
,
'#collapsible'
=
>
TRUE
,
'#collapsed'
=
>
FALSE
,
)
;
//que tipo de misión se ha jugado, hay 3 opciones, normales, especiales, eventos
$form
[
'tipo_mision'
]
[
'mision'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'Que tipo de misión se ha jugado:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'normales'
)
,
'1'
=
>
t
(
'especiales'
)
,
'2'
=
>
t
(
'eventos'
)
,
)
,
'#weight'
=
>
-4,
)
;
//Se muestran las misiones que se pueden jugar.
$form
[
'tipo_mision'
]
[
'clase_mision'
]
=
array
(
'#type'
=
>
'select'
,
'#title'
=
>
t
(
'selecciona la misión que se ha jugado:'
)
,
'#options'
=
>
array
(
'0'
=
>
t
(
'mision 1'
)
,
'1'
=
>
t
(
'mision 2'
)
,
'2'
=
>
t
(
'mision 3'
)
,
)
,
'#weight'
=
>
-3,
)
;
//Resulatdo de la partida
$form
[
'resultado'
]
=
array
(
'#type'
=
>
'fieldset'
,
'#title'
=
>
t
(
'Tipo de resultado'
)
,
'#weight'
=
>
1
,
'#collapsible'
=
>
TRUE
,
'#collapsed'
=
>
FALSE
,
)
;
//selecciona como ha finalizado la partida.
$form
[
'resultado'
]
[
'ganar_perder'
]
=
array
(
'#type'
=
>
'radios'
,
'#title'
=
>
t
(
'Resultado de la partida'
)
,
'#options'
=
>
array
(
t
(
'he ganado'
)
,
t
(
'He empatado'
)
,
t
(
'He perdido'
)
)
,
)
;
//botón de enviar dadtos
$form
[
'submit'
]
=
array
(
'#type'
=
>
'submit'
,
'#value'
=
>
t
(
'guardar'
)
,
)
;
return
$form
;
}
?>
</code>
fapi
form
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<code> <?php /** * Formulario que permite guardar las partidas jugadas * Form to save the game. */ function alta_partida_form($node){ $form['alta_partida'] = array ( '#type' => 'fieldset', '#title' => t('alta de partidas') ); // Nombre del jugador a $form['jugador_a'] = array( '#type' => 'value', '#value' => $user->uid, ); // Nombre del ejercito del jugador a $form['jugador_a_ejercito'] = array( '#type' => 'value', '#value' => $user->profile_ejercito, ); // fieldset para agrupar los datos del jugador b $form['contrincante'] = array( '#type' => 'fieldset', '#title' => t('Datos de tu contrincante'), '#weight' => 5, '#collapsible' => TRUE, '#collapsed' => FALSE, ); // Ejercito del jugador b $form['contrincante']['jugador_b_ejercito'] = array ( '#type' => 'select', '#title' => t('selecciona el ejercito de tu contrincante:'), '#options' => array( '0' => t('Marines'), '1' => t('Orkos'), '2' => t('Eldars'), ), 'default_value' => t('seleccina un ejercito'), '#weight' => -15, ); // Nombre del jugador b $form['contrincante']['jugador_b_'] = array ( '#type' => 'select', '#title' => t('¿Como se llamaba tu contrincante?:'), '#options' => array( '0' => t('General Lee'), '1' => t('Mc Arthur'), '2' => t('Almirante Nelson'), '3' => t('Godoy'), ), '#weight' => -14, ); //fieldset de la campaña $form['campanya'] = array( '#type' => 'fieldset', '#title' => t('Datos de la campaña'), '#weight' => 4, '#collapsible' => TRUE, '#collapsed' => FALSE, ); //nombre de la campanya. $form['campanya']['nombre_campanya'] = array ( '#type' => 'item', '#title' => t('Nombre de la campaña:'), '#value' => $user->profile_campanya, '#weight' => -4, ); //lugar de la partida $form['campanya']['lugar'] = array( '#type' => 'select', '#title' => t('Donde se ha jugado la partida:'), '#options' => array( '0' => t('Paris centro'), '1' => t('Sudeste de paris'), '2' => t('En los suburbios'), '3' => t('En el almacen del puerto'), ), '#weight' => -3, ); //fieldset del tipo de partida $form['tipo_partida'] = array( '#type' => 'fieldset', '#title' => t('Tipo de partida que se ha jugado'), '#weight' => 2, '#collapsible' => TRUE, '#collapsed' => FALSE, ); //tipo de batalla, hace referencia a la cantidad de puntos que se juegan en la partida. $form['tipo_paritda']['tipo_batalla'] = array( '#type' => 'select', '#title' => t('Donde se ha jugado la partida:'), '#options' => array( '0' => t('escaramuzas'), '1' => t('patrullas'), '2' => t('normal'), '3' => t('grande'), '4' => t('enorme'), ), '#weight' => -5, ); //tipo de batalla, hace referencia al tipo de miniaturas, tamaño, que se utiliza en la partida.. $form['tipo_paritda']['tipo_ejercito'] = array( '#type' => 'select', '#title' => t('Donde se ha jugado la partida:'), '#options' => array( '0' => t('06mm a 15mm'), '1' => t('16 mm a 25mm'), '2' => t('26 mm a 35mm'), '3' => t('36mm a 55mm'), '4' => t('barcos'), '5' => t('aviones'), '6' => t('naves espaciales'), ), '#weight' => -4, ); //fieldset del tipo de misión que se ha jugado en la partida $form['tipo_mision'] = array( '#type' => 'fieldset', '#title' => t('Tipo de misión'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => FALSE, ); //que tipo de misión se ha jugado, hay 3 opciones, normales, especiales, eventos $form['tipo_mision']['mision'] = array( '#type' => 'select', '#title' => t('Que tipo de misión se ha jugado:'), '#options' => array( '0' => t('normales'), '1' => t('especiales'), '2' => t('eventos'), ), '#weight' => -4, ); //Se muestran las misiones que se pueden jugar. $form['tipo_mision']['clase_mision'] = array( '#type' => 'select', '#title' => t('selecciona la misión que se ha jugado:'), '#options' => array( '0' => t('mision 1'), '1' => t('mision 2'), '2' => t('mision 3'), ), '#weight' => -3, ); //Resulatdo de la partida $form['resultado'] = array( '#type' => 'fieldset', '#title' => t('Tipo de resultado'), '#weight' => 1, '#collapsible' => TRUE, '#collapsed' => FALSE, ); //selecciona como ha finalizado la partida. $form['resultado']['ganar_perder'] = array( '#type' => 'radios', '#title' => t('Resultado de la partida'), '#options' => array(t('he ganado'), t('He empatado'), t('He perdido')), ); //botón de enviar dadtos $form['submit'] = array ( '#type' => 'submit', '#value' => t('guardar'), ); return $form; } ?> </code>
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.