Jump to content

Module:Contact: Difference between revisions

From nUSA Wiki
No edit summary
No edit summary
Line 7: Line 7:


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


return p
return p

Revision as of 23:46, 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 mw.html.create('form')
        :attr('action', '/wiki/Contact')
        :attr('method', 'POST')
        :wikitext('<label for="subject">Subject:</label>')
        :wikitext('<input type="text" id="subject" name="subject" required><br>')
        :wikitext('<label for="message">Message:</label>')
        :wikitext('<textarea id="message" name="message" required></textarea><br>')
        :wikitext('<input type="hidden" name="username" value="' .. username .. '">')
        :wikitext('<button type="submit">Send</button>')
        :wikitext('</form>')
        :getText()
end

return p