Jump to content

Module:Contact: Difference between revisions

From nUSA Wiki
Created page with "local p = {} function p.form( frame ) local username = mw.title.getCurrentTitle().getText() -- Get the current username (assumes the user is logged in) local subject = frame.args.subject or "" -- Get the subject input, if present local message = frame.args.message or "" -- Get the message input, if present -- Create a simple form for submitting the message return string.format([[ <form action="/w/index.php" method="post"> <input type=..."
 
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


function p.form( frame )
-- Function to render the form
     local username = mw.title.getCurrentTitle().getText()  -- Get the current username (assumes the user is logged in)
function p.form(frame)
     local subject = frame.args.subject or ""  -- Get the subject input, if present
     -- Get the username from the current user (if logged in)
    local message = frame.args.message or ""  -- Get the message input, if present
     local username = mw.title.getCurrentTitle().text


     -- Create a simple form for submitting the message
     -- HTML for the contact form
     return string.format([[
     return '<form action="/wiki/Contact" method="POST">' ..
    <form action="/w/index.php" method="post">
          '<label for="subject">Subject:</label>' ..
        <input type="hidden" name="title" value="Special:Contact">
          '<input type="text" id="subject" name="subject" required><br>' ..
        <input type="hidden" name="username" value="%s">
          '<label for="message">Message:</label>' ..
        <label for="subject">Subject:</label>
          '<textarea id="message" name="message" required></textarea><br>' ..
        <input type="text" name="subject" value="%s" required>
          '<input type="hidden" name="username" value="' .. username .. '">' ..
        <br>
          '<button type="submit">Send</button>' ..
        <label for="message">Message:</label>
          '</form>'
        <textarea name="message" required>%s</textarea>
        <br>
        <input type="submit" value="Send Message">
    </form>
    ]], username, subject, message)
end
end


return p
return p

Revision as of 23:45, 3 January 2025

Documentation for this module may be created at Module:Contact/doc

local p = {}

-- Function to render the form
function p.form(frame)
    -- Get the username from the current user (if logged in)
    local username = mw.title.getCurrentTitle().text

    -- HTML for the contact form
    return '<form action="/wiki/Contact" method="POST">' ..
           '<label for="subject">Subject:</label>' ..
           '<input type="text" id="subject" name="subject" required><br>' ..
           '<label for="message">Message:</label>' ..
           '<textarea id="message" name="message" required></textarea><br>' ..
           '<input type="hidden" name="username" value="' .. username .. '">' ..
           '<button type="submit">Send</button>' ..
           '</form>'
end

return p